PhotoMosaic: reorder methods to be alphabetically ordered

This commit is contained in:
Aaron van Geffen 2023-11-29 22:47:51 +01:00
parent aeaff887ca
commit 8e0e642d34

View File

@ -8,10 +8,9 @@
class PhotoMosaic class PhotoMosaic
{ {
private $queue = [];
const NUM_DAYS_CUTOFF = 7; const NUM_DAYS_CUTOFF = 7;
private AssetIterator $iterator; private AssetIterator $iterator;
private $queue = [];
public function __construct(AssetIterator $iterator) public function __construct(AssetIterator $iterator)
{ {
@ -23,21 +22,9 @@ class PhotoMosaic
$this->iterator->clean(); $this->iterator->clean();
} }
public static function getRecentPhotos() private static function daysApart(Image $a, Image $b)
{ {
return new self(AssetIterator::getByOptions([ return $a->getDateCaptured()->diff($b->getDateCaptured())->days;
'tag' => 'photo',
'order' => 'date_captured',
'direction' => 'desc',
'limit' => 15, // worst case: 3 rows * (portrait + 4 thumbs)
]));
}
private static function matchTypeMask(Image $image, $type_mask)
{
return ($type_mask & Image::TYPE_PANORAMA) && $image->isPanorama() ||
($type_mask & Image::TYPE_LANDSCAPE) && $image->isLandscape() ||
($type_mask & Image::TYPE_PORTRAIT) && $image->isPortrait();
} }
private function fetchImage($desired_type = Image::TYPE_PORTRAIT | Image::TYPE_LANDSCAPE | Image::TYPE_PANORAMA, Image $refDateImage = null) private function fetchImage($desired_type = Image::TYPE_PORTRAIT | Image::TYPE_LANDSCAPE | Image::TYPE_PANORAMA, Image $refDateImage = null)
@ -66,25 +53,14 @@ class PhotoMosaic
return false; return false;
} }
private function pushToQueue(Image $image) public static function getRecentPhotos()
{ {
$this->queue[] = $image; return new self(AssetIterator::getByOptions([
} 'tag' => 'photo',
'order' => 'date_captured',
private static function orderPhotos(Image $a, Image $b) 'direction' => 'desc',
{ 'limit' => 15, // worst case: 3 rows * (portrait + 4 thumbs)
// Show images of highest priority first. ]));
$priority_diff = $a->getPriority() - $b->getPriority();
if ($priority_diff !== 0)
return -$priority_diff;
// In other cases, we'll just show the newest first.
return $a->getDateCaptured() <=> $b->getDateCaptured();
}
private static function daysApart(Image $a, Image $b)
{
return $a->getDateCaptured()->diff($b->getDateCaptured())->days;
} }
public function getRow() public function getRow()
@ -171,4 +147,27 @@ class PhotoMosaic
else else
return [$photos, 'landscapes']; return [$photos, 'landscapes'];
} }
private static function matchTypeMask(Image $image, $type_mask)
{
return ($type_mask & Image::TYPE_PANORAMA) && $image->isPanorama() ||
($type_mask & Image::TYPE_LANDSCAPE) && $image->isLandscape() ||
($type_mask & Image::TYPE_PORTRAIT) && $image->isPortrait();
}
private static function orderPhotos(Image $a, Image $b)
{
// Show images of highest priority first.
$priority_diff = $a->getPriority() - $b->getPriority();
if ($priority_diff !== 0)
return -$priority_diff;
// In other cases, we'll just show the newest first.
return $a->getDateCaptured() <=> $b->getDateCaptured();
}
private function pushToQueue(Image $image)
{
$this->queue[] = $image;
}
} }