Add tests for featured thumbnail generation; apply Pint formatting and related edits
This commit is contained in:
@@ -27,6 +27,8 @@ class ArtworkService
|
||||
{
|
||||
protected int $cacheTtl = 3600; // seconds
|
||||
|
||||
private ?bool $featureTypeColumnExists = null;
|
||||
|
||||
public function __construct(
|
||||
private readonly ContentTypeSlugResolver $contentTypeResolver,
|
||||
private readonly ArtworkMaturityService $maturity,
|
||||
@@ -340,7 +342,7 @@ class ArtworkService
|
||||
*/
|
||||
private function featuredBaseQuery(?int $type): Builder
|
||||
{
|
||||
return Artwork::query()
|
||||
$query = Artwork::query()
|
||||
->select('artworks.*')
|
||||
->join('artwork_features as af', 'af.artwork_id', '=', 'artworks.id')
|
||||
->leftJoin('artwork_medal_stats as aas', 'aas.artwork_id', '=', 'artworks.id')
|
||||
@@ -349,10 +351,13 @@ class ArtworkService
|
||||
->where(function ($query): void {
|
||||
$query->whereNull('af.expires_at')
|
||||
->orWhere('af.expires_at', '>', now());
|
||||
})
|
||||
->when($type !== null, function ($q) use ($type) {
|
||||
$q->where('af.type', $type);
|
||||
});
|
||||
|
||||
if ($type !== null && $this->featuredTypeColumnExists()) {
|
||||
$query->where('af.type', $type);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
private function applyFeaturedEligibilityFilters(Builder $query): void
|
||||
@@ -384,6 +389,15 @@ class ArtworkService
|
||||
return $this->applyFeaturedOrdering($query);
|
||||
}
|
||||
|
||||
private function featuredTypeColumnExists(): bool
|
||||
{
|
||||
if ($this->featureTypeColumnExists === null) {
|
||||
$this->featureTypeColumnExists = Schema::hasColumn('artwork_features', 'type');
|
||||
}
|
||||
|
||||
return $this->featureTypeColumnExists;
|
||||
}
|
||||
|
||||
private function featuredHeroSelectionQuery(?int $type): Builder
|
||||
{
|
||||
$query = $this->featuredBaseQuery($type);
|
||||
|
||||
Reference in New Issue
Block a user