refactor(feed): address /code-review high findings on the E2 stack
Review round on the E2 stack (S1-S5). No correctness bugs; the surviving low/medium findings addressed: - altitude (#1): extract the shared `tags_by_category` helper used by BOTH filtered_query (SQL tag WHERE) and feed_summary (Python facet/count), removing the category-grouping duplication, and add bidirectional "keep in lockstep — equivalence-tested by test_feed_summary_matches_count_plus_facets" comments so the SQL<->Python tag rule can't silently drift. - test-coverage (#2): the /feed/summary equivalence test seeded only system tags, leaving the `ChannelTag.user_id == user.id` visibility branch untested. Add a user-owned Tag + link + two combos; the suite is now 346 (was 344) and the new cases pass (feed_summary agrees with /feed/count + /facets on user-visible tags). - dead-code (#3): annotate get_feed_count, get_facets, and the FE api.feedCount/ facets as "SUPERSEDED by /feed/summary — kept only as the equivalence oracle; retire together" so the intentionally-retained surface reads as deliberate. Not changed (confirmed no-op): the search channel-name resolve (#4) is once-per-request on a 633-row table and a deliberate pre-resolve for PERF-12's BitmapOr plan; the facet loop (#5) already computes passes() once per (channel, category) with a distinct exclude each, so there is no recomputation. Gate green: ruff + 346 pytest; frontend tsc/knip/prettier (FE change is a comment).
This commit is contained in:
@@ -113,6 +113,8 @@ function feedQuery(f: FeedFilters, cursor: string | null, limit: number): string
|
||||
export const feedApi = {
|
||||
feed: (f: FeedFilters, cursor: string | null, limit: number): Promise<FeedResponse> =>
|
||||
req(`/api/feed?${feedQuery(f, cursor, limit)}`),
|
||||
// SUPERSEDED by feedSummary (PERF-13) — no component calls this anymore; the backend /feed/count
|
||||
// endpoint it targets is kept only as the /feed/summary equivalence-test oracle. Retire together.
|
||||
feedCount: (f: FeedFilters): Promise<{ count: number }> =>
|
||||
req(`/api/feed/count?${filterParams(f).toString()}`),
|
||||
// Live YouTube search: results are materialised into the catalog and returned as feed cards.
|
||||
@@ -129,6 +131,8 @@ export const feedApi = {
|
||||
// the now-orphaned, un-kept videos). Returns how many videos were removed.
|
||||
clearSearch: (videoIds: string[]): Promise<{ removed: number }> =>
|
||||
req("/api/search/clear", { method: "POST", body: JSON.stringify({ video_ids: videoIds }) }),
|
||||
// SUPERSEDED by feedSummary (PERF-13) — no component calls this anymore; the backend /facets
|
||||
// endpoint it targets is kept only as the /feed/summary equivalence-test oracle. Retire together.
|
||||
facets: (f: FeedFilters): Promise<{ counts: Record<string, number> }> =>
|
||||
req(`/api/facets?${filterParams(f).toString()}`),
|
||||
// The sidebar's total count + per-tag channel facets in ONE request + ONE grouped query, replacing
|
||||
|
||||
Reference in New Issue
Block a user