Files
nexusphp/app/Console/Commands/Cleanup.php
2023-05-06 02:06:13 +08:00

53 lines
1.8 KiB
PHP

<?php
namespace App\Console\Commands;
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
*/
protected $signature = 'cleanup {--action=} {--begin_id=} {--end_id=} {--request_id=} {--delay=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Cleanup async job trigger, options: --begin_id, --end_id, --request_id, --delay, --action (seed_bonus, seeding_leeching_time, seeders_etc)';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$action = $this->option('action');
$beginId = $this->option('begin_id');
$endId = $this->option('end_id');
$commentRequestId = $this->option('request_id');
$delay = $this->option('delay') ?: 0;
$this->info("beginId: $beginId, endId: $endId, commentRequestId: $commentRequestId, delay: $delay, action: $action");
if ($action == 'seed_bonus') {
CalculateUserSeedBonus::dispatch($beginId, $endId, $commentRequestId)->delay($delay);
} elseif ($action == 'seeding_leeching_time') {
UpdateUserSeedingLeechingTime::dispatch($beginId, $endId, $commentRequestId)->delay($delay);
}elseif ($action == 'seeders_etc') {
UpdateTorrentSeedersEtc::dispatch($beginId, $endId, $commentRequestId)->delay($delay);
} else {
$msg = "[$commentRequestId], Invalid action: $action";
do_log($msg, 'error');
$this->error($msg);
}
return Command::SUCCESS;
}
}