flower
/

review · segments

Design 'Followed Only' filter for /authors (40-favorites-filter.md)

claude 53 events 1 segments authors-location-optimization-plan

segment 1 of 1

Design 'Followed only' filter for /authors (40-favorites-filter.md)

Done

The assistant read the mandatory production facts (00-PRODUCTION-FACTS.md), performance foundation (10-perf-and-indexing.md), the FavorableTrait trait, User model followed-reddit-user methods, the markable_favorites table schema (from mysql-schema.sql), the RedditUserIndex Livewire component, and the blade view filter bar. Based on this research, the assistant wrote a detailed design document at docs/authors-optimization/40-favorites-filter.md covering the toggle implementation: reusing the user's cached followed-reddit-users collection (60-min TTL, busted on follow/unfollow), resolving IDs into a whereIntegerInRaw('id', $ids) clause on the existing query, handling auth-gating (hide toggle when guest), composing with other filters (search, location, sort), an empty state message if the user follows no one, and a lightweight covering index on markable_favorites (user_id, markable_type, markable_id). The design explicitly notes this feature sidesteps the dense-location filesort because the followed set is tiny per user.

outcome

Design document written at docs/authors-optimization/40-favorites-filter.md with build-ready implementation details and known risks.

next steps

key decisions

  • Reuse the existing 60-min cached followed-reddit-users collection from User model (cachedFollowedRedditUsersCollection) rather than querying markable_favorites directly on every render.
  • Resolve followed IDs first, then apply whereIntegerInRaw('id', $ids) on the RedditUser query — mirroring the Scout-branch pattern already in RedditUserIndex::render.
  • No new index on the 7.9M location_reddit_user pivot is needed for this feature because the candidate set is bounded by the user's (small) follow list.
  • The toggle is auth-gated: it appears in the filter bar only when the user is logged in; a guest sees no toggle.
  • If the user has zero followed users and toggles 'Followed only', show an empty-state message (no card grid) with the text "You haven't followed any authors yet" and a CTA button linking to /authors (without filter).
  • Leave the related 'In my favorite locations' toggle to doc 50-favorite-locations-and-settings.md.
  • The followedRedditUsersCacheKey naming ('user_followed_reddit_users_'.$id) violates the namespace:purpose:vN convention but is shared with the navbar; renaming is flagged as a future cleanup but not changed here.
  • When followed_only is combined with search (query string), two whereIntegerInRaw clauses intersect; tests should cover this composition.

open questions

  • What is the maximum per-user follow count for markable_type=App\Models\RedditUser in production? The design assumes tens or hundreds, not tens of thousands. Should verify against prod markable_favorites.
  • Does the cache key naming convention need to be updated to namespace:purpose:vN per CLAUDE.md conventions? Flagged as out-of-scope cleanup.
  • Should the empty-state CTA ('Explore authors') link to /authors without filters or to a discoverability page? Decided as /authors without filter for simplicity.

6 days ago 6 days ago