tip #42: Most-Viewed Recipes widget

This commit is contained in:
Hermes AI Bot
2026-07-23 16:00:39 +00:00
parent 8a20287dff
commit 6340c6f565
2 changed files with 23 additions and 0 deletions
@@ -0,0 +1,22 @@
---
tip_number: 42
date: 2026-07-23
category: data
status: pending
---
# Tip #42 — Most-Viewed Recipes widget
**Date:** 2026-07-23
**Category:** data
**Source:** MC-Survival Wiki Daily Tip (cron @ 18:00 MESZ)
## Most-Viewed Recipes widget
Track recipe views in a write-only RecipeView { recipeId, userId?, createdAt } table, aggregate the top 10 over the last 30 days, and render them as a widget on the homepage. It solves the 'what is popular' discovery problem: new visitors have no signal about which recipes are most useful, and a 'Most-Viewed' list is the universal way to bootstrap that. The signal is engagement analytics — a top-10 list consistently outperforms a 'featured' or editor-picked list, because the data reflects what the community actually uses. Caching the aggregate for 1 hour via TanStack Query keeps the cost negligible, and writing the view events is a single insert per page load.
## Implementation tips
1. Track views in a RecipeView { recipeId, userId?, createdAt } table (write-only, no read overhead).
2. Aggregate query: top 10 by count, last 30 days, exclude bots (no User-agent filter — keep simple).
3. Cache the result for 1h with TanStack Query — re-aggregating on every page load is wasteful.