Files
nexusphp/app/Console/Commands/Cleanup.php

55 lines
2.0 KiB
PHP
Raw Normal View History

<?php
namespace App\Console\Commands;
2022-11-05 18:43:49 +08:00
use App\Jobs\CalculateUserSeedBonus;
use App\Jobs\UpdateTorrentSeedersEtc;
use App\Jobs\UpdateUserSeedingLeechingTime;
use Illuminate\Console\Command;
class Cleanup extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
2024-02-22 12:03:07 +08:00
protected $signature = 'cleanup {--action=} {--begin_id=} {--id_str=} {--end_id=} {--request_id=} {--delay=} {--id_redis_key=}';
/**
* The console command description.
*
* @var string
*/
2024-02-21 21:11:16 +08:00
protected $description = 'Cleanup async job trigger, options: --begin_id, --end_id, --id_str, --request_id, --delay, --id_redis_key,--action (seed_bonus, seeding_leeching_time, seeders_etc)';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$action = $this->option('action');
2022-11-05 18:43:49 +08:00
$beginId = $this->option('begin_id');
$endId = $this->option('end_id');
2023-07-17 02:00:20 +08:00
$idStr = $this->option('id_str') ?: "";
2024-02-21 21:11:16 +08:00
$idRedisKey = $this->option('id_redis_key') ?: "";
2022-11-05 18:43:49 +08:00
$commentRequestId = $this->option('request_id');
2023-05-06 02:06:13 +08:00
$delay = $this->option('delay') ?: 0;
2024-02-21 21:11:16 +08:00
$this->info("beginId: $beginId, endId: $endId, idStr: $idStr, idRedisKey: $idRedisKey, commentRequestId: $commentRequestId, delay: $delay, action: $action");
if ($action == 'seed_bonus') {
2024-02-21 21:11:16 +08:00
CalculateUserSeedBonus::dispatch($beginId, $endId, $idStr, $idRedisKey, $commentRequestId)->delay($delay);
} elseif ($action == 'seeding_leeching_time') {
2024-02-21 21:11:16 +08:00
UpdateUserSeedingLeechingTime::dispatch($beginId, $endId, $idStr, $idRedisKey, $commentRequestId)->delay($delay);
2022-11-05 18:43:49 +08:00
}elseif ($action == 'seeders_etc') {
2024-02-21 21:11:16 +08:00
UpdateTorrentSeedersEtc::dispatch($beginId, $endId, $idStr, $idRedisKey, $commentRequestId)->delay($delay);
} else {
2022-11-05 18:43:49 +08:00
$msg = "[$commentRequestId], Invalid action: $action";
do_log($msg, 'error');
$this->error($msg);
}
return Command::SUCCESS;
}
}