-
Notifications
You must be signed in to change notification settings - Fork 0
chore: remove runtime usage of image_url from commands and query services #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,13 +33,15 @@ public function findByIdsPreserveOrder(array $ids): Collection | |||||||||
| 'world_heritage_sites.latitude', | ||||||||||
| 'world_heritage_sites.longitude', | ||||||||||
| 'world_heritage_sites.short_description', | ||||||||||
| 'world_heritage_sites.image_url', | ||||||||||
| ]) | ||||||||||
| ->with([ | ||||||||||
| 'countries' => function ($q) { | ||||||||||
| $q->select('countries.state_party_code', 'countries.name_en', 'countries.name_jp', 'countries.region') | ||||||||||
| ->orderBy('countries.state_party_code', 'asc'); | ||||||||||
| }, | ||||||||||
| 'images' => function ($imageQuery) { | ||||||||||
| $imageQuery->where('is_primary', true)->limit(1); | ||||||||||
|
||||||||||
| $imageQuery->where('is_primary', true)->limit(1); | |
| $imageQuery->where('is_primary', true); |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s no test coverage asserting that findByIdsPreserveOrder() returns the expected primary image per site (especially when multiple site IDs are requested). Given the eager-load constraint on images, adding a test that seeds images for at least 2 sites and verifies each model has its primary image loaded would prevent regressions and catch issues like global eager-load limits.
| $imageQuery->where('is_primary', true)->limit(1); | |
| $imageQuery->where('is_primary', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
countriesrelation here is used to build arrays that are sent to Algolia. Without an explicit ordering, the DB may return countries in a non-deterministic order, which can cause unnecessary Algolia updates (array order changes) and make results harder to reason about. Consider adding anorderBy('countries.state_party_code')(or another stable key) in this eager-load constraint.