| @@ -1,10 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Mgleis\DiskUsageInsights\Frontend\Controller; |
| 3 | 3 | |
| 4 | 4 | use Mgleis\DiskUsageInsights\Domain\DatabaseRepository; |
| 5 | +use Mgleis\DiskUsageInsights\Domain\FileEntryRepository; | |
| 6 | +use Mgleis\DiskUsageInsights\Domain\SnapshotRepository; | |
| 5 | 7 | use Mgleis\DiskUsageInsights\Plugin; |
| 6 | 8 | use Mgleis\PhpSqliteJobQueue\Job; |
| 9 | +use Mgleis\PhpSqliteJobQueue\Queue; | |
| 7 | 10 | use Mgleis\PhpSqliteJobQueue\Worker; |
| 8 | 11 | |
| 9 | 12 | class ScanWorkerController { |
| 10 | 13 | |
| @@ -25,12 +28,11 @@ | ||
| 25 | 28 | } |
| 26 | 29 | |
| 27 | 30 | $w = (new Worker($database->q)) |
| 28 | 31 | ->withMaxTotalRuntimeInSeconds(5) |
| 29 | - ->withSleepTimeBetweenJobsInMilliseconds(0) | |
| 30 | - ->withSleepTimeOnEmptyQueueInMilliseconds(0) | |
| 32 | + ->withSleepTimeBetweenJobsInMilliseconds(1) | |
| 33 | + ->withSleepTimeOnEmptyQueueInMilliseconds(1) | |
| 31 | 34 | ; |
| 32 | - | |
| 33 | 35 | $w->process(function(Job $job) use ($database) { |
| 34 | 36 | $reflect = new \ReflectionClass($job->payload['type']); |
| 35 | 37 | $instance = $reflect->newInstanceArgs($job->payload['args']); |
| 36 | 38 | $instance->setQueue($database->q); |
| @@ -35,12 +37,9 @@ | ||
| 35 | 37 | $instance = $reflect->newInstanceArgs($job->payload['args']); |
| 36 | 38 | $instance->setQueue($database->q); |
| 37 | 39 | $instance->setFileEntryRepository($database->fileEntryRepository); |
| 38 | 40 | $instance->setSnapshotRepository($database->snapshotRepository); |
| 39 | - | |
| 40 | - $database->q->db->beginTransaction(); | |
| 41 | 41 | $instance->work(); |
| 42 | - $database->q->db->commit(); | |
| 43 | 42 | }); |
| 44 | 43 | |
| 45 | 44 | wp_die(); // All ajax handlers should die when finished |
| 46 | 45 | } |