Skip to content

Add table relation cache for smart album - #4551

Closed
ildyria wants to merge 2 commits into
masterfrom
relation-smart-album-user-thumb
Closed

Add table relation cache for smart album#4551
ildyria wants to merge 2 commits into
masterfrom
relation-smart-album-user-thumb

Conversation

@ildyria

@ildyria ildyria commented Jul 21, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 21, 2026 18:39
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d55f08b0-56eb-4cdd-9db0-de40e5d36aab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a per-viewer thumb (cover photo) cache for smart/tag/person albums and keeps it warm by reacting to photo mutations. It also refactors smart-album and relation querying to support an explicit “as seen by user” context for queued recomputation.

Changes:

  • Add album_user_thumbs cache table + AlbumUserThumb model, and a read-through caching trait used by smart/tag/person albums.
  • Add a queued recomputation job plus an event listener wired to photo lifecycle/mutation events (tags/persons/rating/highlight).
  • Refactor smart albums and tag/person relations to resolve user context consistently (supporting offline/queued recompute).

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
database/migrations/2026_07_21_000000_create_album_user_thumbs_table.php Adds new cache table for per-viewer album thumbs.
app/Models/AlbumUserThumb.php Introduces model for the cache table and its relations.
app/Models/Extensions/CachesAlbumUserThumb.php Adds read-through thumb caching for albums.
app/SmartAlbums/BaseSmartAlbum.php Adds explicit user context and routes thumb generation through cache.
app/SmartAlbums/UnsortedAlbum.php Uses resolved user context instead of Auth directly.
app/SmartAlbums/MyRatedPicturesAlbum.php Uses resolved user context instead of Auth directly.
app/SmartAlbums/MyBestPicturesAlbum.php Uses resolved user context instead of Auth directly.
app/Relations/BaseHasManyPhotos.php Adds overridable resolved-user logic for non-standard album relations.
app/Relations/HasManyPhotosByTag.php Supports explicit user context for eager constraints.
app/Relations/HasManyPhotosByPerson.php Supports explicit user context for eager constraints.
app/Jobs/RecomputeAlbumUserThumbsJob.php Adds queued recomputation of cached thumbs for already-cached viewers.
app/Listeners/RecomputeAlbumUserThumbsOnPhotoChange.php Dispatches recomputation jobs on relevant photo mutation events.
app/Providers/EventServiceProvider.php Wires new events to the recomputation listener.
app/Http/Controllers/Gallery/PhotoController.php Dispatches new events on tag changes and highlight toggles.
app/Http/Controllers/Gallery/AlbumController.php Dispatches recomputation jobs when tag/person albums’ membership changes.
app/Http/Controllers/AiVision/FaceController.php Dispatches new events when photo-person associations change.
app/Events/PhotoTagsChanged.php New event for tag changes.
app/Events/PhotoStarToggled.php New event for highlight/star toggle.
app/Events/PhotoRatingChanged.php New event for rating changes.
app/Events/PhotoPersonsChanged.php New event for person changes.
app/Actions/Photo/Rating.php Dispatches new rating-changed event.
app/Actions/Album/Delete.php Cleans cache rows when tag/person albums are deleted.
app/Models/TagAlbum.php Routes thumb generation through cache.
app/Models/PersonAlbum.php Routes thumb generation through cache.

Comment thread app/Models/Extensions/CachesAlbumUserThumb.php
Comment thread app/Http/Controllers/Gallery/PhotoController.php
Comment thread app/Listeners/RecomputeAlbumUserThumbsOnPhotoChange.php
@ildyria ildyria closed this Jul 25, 2026
@ildyria
ildyria deleted the relation-smart-album-user-thumb branch July 25, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants