| 1 |
<?php |
| 2 |
|
| 3 |
namespace Mgleis\DiskUsageInsights\Domain\Collect; |
| 4 |
|
| 5 |
use Mgleis\DiskUsageInsights\Domain\Jobs\BaseJob; |
| 6 |
|
| 7 |
class DetermineLastModifiedDateJob extends BaseJob { |
| 8 |
|
| 9 |
private int $skip; |
| 10 |
private int $count; |
| 11 |
private int $totalCount; |
| 12 |
|
| 13 |
public function __construct(int $skip, int $count, int $totalCount) { |
| 14 |
$this->skip = $skip; |
| 15 |
$this->count = $count; |
| 16 |
$this->totalCount = $totalCount; |
| 17 |
} |
| 18 |
|
| 19 |
public function work() { |
| 20 |
$this->log(self::class); |
| 21 |
$fileEntries = $this->fileEntryRepository->get($this->skip, $this->count); |
| 22 |
|
| 23 |
$root = $this->snapshotRepository->load()->root; |
| 24 |
foreach ($fileEntries as $fileEntry) { |
| 25 |
|
| 26 |
$absoluteFilename = $this->fileEntryRepository->calcFullPath($fileEntry, $root); |
| 27 |
|
| 28 |
$fileEntry->last_modified_date = filemtime($absoluteFilename); |
| 29 |
$this->fileEntryRepository->createOrUpdate($fileEntry); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
public function toArray() { |
| 34 |
return ['type' => self::class, 'args' => [$this->skip, $this->count, $this->totalCount]]; |
| 35 |
} |
| 36 |
|
| 37 |
public function toDescription(): string { |
| 38 |
return sprintf('Determining last modified dates... %s%%', round(100 * $this->skip / $this->totalCount)); |
| 39 |
} |
| 40 |
} |
| 41 |
|