69 lines
2.2 KiB
PHP
69 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Remote\CopyManga;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
use Illuminate\Support\Facades\Log;
|
|
use romanzipp\QueueMonitor\Traits\IsMonitored;
|
|
|
|
class RemotePrefetch implements ShouldQueue
|
|
{
|
|
use IsMonitored, Queueable;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct(public string $action, public array $parameters = [])
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$this->queueProgress(0);
|
|
$copyManga = new CopyManga();
|
|
|
|
switch ($this->action) {
|
|
case 'chapter':
|
|
Log::info("JOB RemotePrefetch START, action '{$this->action}', Pathword: {$this->parameters['pathword']}, UUID: {$this->parameters['uuid']}");
|
|
$this->queueData([
|
|
'action' => $this->action,
|
|
'pathword' => $this->parameters['pathword'],
|
|
'uuid' => $this->parameters['uuid']
|
|
]);
|
|
|
|
$copyManga->chapter($this->parameters['pathword'], $this->parameters['uuid']);
|
|
|
|
Log::info("JOB RemotePrefetch END, action '{$this->action}'");
|
|
break;
|
|
case 'chapters':
|
|
// TODO:
|
|
break;
|
|
case 'comics':
|
|
Log::info("JOB RemotePrefetch START, action '{$this->action}', Offset: {$this->parameters['offset']}");
|
|
$this->queueData([
|
|
'action' => $this->action,
|
|
'offset' => $this->parameters['offset'],
|
|
'limit' => $this->parameters['limit'],
|
|
'top' => $this->parameters['top'],
|
|
'params' => $this->parameters['params']
|
|
]);
|
|
|
|
$copyManga->comics($this->parameters['offset'], $this->parameters['limit'], $this->parameters['top'], $this->parameters['params']);
|
|
|
|
Log::info("JOB RemotePrefetch END, action '{$this->action}'");
|
|
break;
|
|
default:
|
|
Log::info("JOB RemotePrefetch Unknown action '{$this->action}'");
|
|
break;
|
|
}
|
|
|
|
$this->queueProgress(100);
|
|
}
|
|
}
|