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