PhotoMosaic: keep queue ordered by date captured

This commit is contained in:
2023-12-19 17:16:57 +01:00
parent 6150922a1f
commit d2fa547257
2 changed files with 27 additions and 3 deletions

View File

@@ -8,6 +8,7 @@
class PhotoMosaic
{
private $descending;
private AssetIterator $iterator;
private $layouts;
private $processedImages = 0;
@@ -19,6 +20,7 @@ class PhotoMosaic
{
$this->iterator = $iterator;
$this->layouts = $this->availableLayouts();
$this->descending = $iterator->isDescending();
}
public function __destruct()
@@ -143,8 +145,17 @@ class PhotoMosaic
return -$priority_diff;
}
private function orderQueueByDate()
{
usort($this->queue, function($a, $b) {
$score = $a->getDateCaptured() <=> $b->getDateCaptured();
return $score * ($this->descending ? -1 : 1);
});
}
private function pushToQueue(Image $image)
{
$this->queue[] = $image;
$this->orderQueueByDate();
}
}