feat: search matches ingredients/tags, add tag filter chips to Explore
Search previously only matched title/description. Now also matches ingredient rawName (EXISTS subquery) and tags (unnest+ILIKE) via sequential scan — fine at current scale, flagged for a trigram/GIN index if it gets slow. Explore also shows the 12 most-used public tags as clickable chips that AND-filter results via a new `tags` query param (array containment). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -76,11 +76,26 @@ export default async function ExplorePage({
|
||||
const trending: RecipeResult[] = trendingRows.map(({ favoriteCount: _fc, ...r }) => r);
|
||||
const recent: RecipeResult[] = recentRows;
|
||||
|
||||
// Most-used tags across public recipes — shown as filter chips on the
|
||||
// search bar so browsing by tag doesn't require typing the exact word.
|
||||
const popularTagsResult = await db.execute<{ tag: string }>(sql`
|
||||
select tag, count(*) as usage_count
|
||||
from recipes r
|
||||
inner join users u on r.author_id = u.id
|
||||
cross join lateral unnest(r.tags) as tag
|
||||
where r.visibility = 'public' and u.is_private = false
|
||||
group by tag
|
||||
order by usage_count desc
|
||||
limit 12
|
||||
`);
|
||||
const popularTags = popularTagsResult.map((r) => r.tag);
|
||||
|
||||
return (
|
||||
<ExplorePageContent
|
||||
trending={trending}
|
||||
recent={recent}
|
||||
initialQuery={q ?? ""}
|
||||
popularTags={popularTags}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user