diff --git a/src/app/discover/page.tsx b/src/app/discover/page.tsx index 8a5a1d02..f742e8af 100644 --- a/src/app/discover/page.tsx +++ b/src/app/discover/page.tsx @@ -24,40 +24,14 @@ export default async function DiscoverPage({ ); } - let storylines: Storyline[] = []; - - if (tab === "completed") { - const { data } = await supabase - .from("storylines") - .select("*") - .eq("hidden", false) - .eq("sunset", true) - .order("plot_count", { ascending: false }) - .limit(50) - .returns(); - storylines = data ?? []; - } else { - // "new" is the default; "trending" and "rising" fall back to "new" ordering - // until trading data is available (Phase 5) - const { data } = await supabase - .from("storylines") - .select("*") - .eq("hidden", false) - .eq("sunset", false) - .order("block_timestamp", { ascending: false }) - .limit(50) - .returns(); - storylines = data ?? []; - } + const storylines = await queryTab(supabase, tab); return (

Discover

-

- Browse stories on PlotLink -

+

Browse stories on PlotLink

@@ -80,3 +54,64 @@ export default async function DiscoverPage({
); } + +async function queryTab( + supabase: ReturnType & object, + tab: Tab, +): Promise { + switch (tab) { + case "new": { + const { data } = await supabase + .from("storylines") + .select("*") + .eq("hidden", false) + .eq("sunset", false) + .order("block_timestamp", { ascending: false }) + .limit(50) + .returns(); + return data ?? []; + } + + case "completed": { + const { data } = await supabase + .from("storylines") + .select("*") + .eq("hidden", false) + .eq("sunset", true) + .order("plot_count", { ascending: false }) + .limit(50) + .returns(); + return data ?? []; + } + + // TODO [Phase 5 / P5-6]: Replace with composite ranking signals + // (unique buyer count, holder diversity, recent trading activity). + // See ROADMAP.md P5-6a for the ranking formula spec. + case "trending": { + const { data } = await supabase + .from("storylines") + .select("*") + .eq("hidden", false) + .eq("sunset", false) + .order("block_timestamp", { ascending: false }) + .limit(50) + .returns(); + return data ?? []; + } + + // TODO [Phase 5 / P5-6]: Replace with acceleration-based ranking + // (stories with accelerating trading activity vs prior period). + // See ROADMAP.md P5-6b for the rising formula spec. + case "rising": { + const { data } = await supabase + .from("storylines") + .select("*") + .eq("hidden", false) + .eq("sunset", false) + .order("block_timestamp", { ascending: false }) + .limit(50) + .returns(); + return data ?? []; + } + } +}