Repository navigation
feat(discovery): Discovery 2.0 quick filters, home highlight strips, and card statement freshness - #326
Conversation
…and card statement freshness
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
PO acceptance: merge at e2a6923 Independent PO flagship review (901637c1-aefe-4c17-867c-f2b800df8fc5): APPROVE (0 P0/P1/P2 findings).
|
Refs #318
Depends on Phase 1 DB migration
DOS/DOS.Me#1886(20261202120000_give_discovery_v2_filters.sql, merged & verified on Supabase Beta37ef37820ff89ad93a0e75f0f3a3e2e11d229bd6).Summary
apps/web/src/lib/campaigns.ts):DiscoverySortandDISCOVERY_SORTSwith"ending_soon"(Sắp hết hạn),"almost_funded"(Sắp đạt mục tiêu), and"recently_audited"(Mới cập nhật sao kê), plusDISCOVERY_HIGHLIGHT_PILLSandisDiscoveryHighlightSort.listCampaignStatementFreshness(db, campaignIds)overgive.public_campaign_statement_freshness(uuid[])(deduplicates IDs, chunks by 100, validates timestamps, fails closed on RPC error)./campaigns(apps/web/src/app/campaigns/page.tsx):FilterNav+ScrollRow+TagLink) and sort menu options for"Sắp hết hạn","Sắp đạt mục tiêu", and"Mới cập nhật sao kê".live;recently_auditedpairs withallor preservesended; re-clicking active pill toggles back tofeatured),nameFrom="xl"on the sort menu so1024pxnever overflows, filteredEmptyStatefor highlight modes, and verified statement freshness fetched only onrecently_audited(excludingapproved/prelaunch)./(apps/web/src/app/page.tsx):"Sắp đạt mục tiêu"(/campaigns?sort=almost_funded) and"Minh bạch sao kê gần đây"(/campaigns?status=all&sort=recently_audited) strips, cleanly hidden when empty, with parallelized queries, deduplicated totals, distinctaria-labellinks, and defense-in-depth exclusion ofapprovedprelaunch rows.apps/web/src/components/CampaignCard.tsx):lastStatementAtdisplaying"Sao kê mới nhất: DD/MM/YYYY"(text-sm text-primary tabular-nums), strictly suppressed onprelaunch(status === "approved") cards and invalid dates.Verification
pnpm format:check: PASSpnpm lint: PASSpnpm typecheck: PASSpnpm test: PASS (201/201 test files, expanded unit/component/RSC coverage incampaigns.test.ts,CampaignCard.test.ts,campaigns/page.test.ts,page.test.ts)pnpm build: PASS📌 TL;DR
This PR introduces "Discovery 2.0" by adding three new campaign sorting modes (
ending_soon,almost_funded,recently_audited) and a newFilterNavcomponent for quick-filter pills on the campaigns page. It also enhances the homepage with dynamic highlight strips for these new categories and adds alastStatementAtproperty toCampaignCardto display verified bank statement freshness dates.🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/lib/campaigns.tsDiscoverySorttypes andDISCOVERY_HIGHLIGHT_PILLSconstants. ImplementedlistCampaignStatementFreshnessto fetch verified statement timestamps via RPC, including chunking and fail-closed error handling.apps/web/src/lib/campaigns.test.tslistCampaignStatementFreshnessfunction (including edge cases like empty IDs, chunking, and error handling).apps/web/src/components/CampaignCard.tsxlastStatementAtprop. Logic to validate the date and strictly suppress the display for pre-launch (approved) campaigns. Renders "Sao kê mới nhất: [date]" if valid.apps/web/src/components/CampaignCard.test.tsapps/web/src/app/campaigns/page.tsxFilterNavfor quick-filter pills. Updated data fetching to include statement freshness when sorting byrecently_audited. AdjustedhasFilterlogic to account for highlight sorts.apps/web/src/app/campaigns/page.test.tsapps/web/src/app/page.tsxalmost_funded,recently_audited) in parallel. ExtractedCampaignStripcomponent to reuse the card grid layout for the new sections.apps/web/src/app/page.test.ts📊 Architectural Flow
sequenceDiagram participant Client as Browser participant Page as Campaigns/Home Page participant Lib as campaigns.ts participant DB as Supabase RPC Note over Client,Page: User navigates to /campaigns or / alt Campaigns Page Client->>Page: Request /campaigns?sort=recently_audited Page->>Lib: listPublicCampaigns(...) Lib->>DB: rpc:discover_campaigns DB-->>Lib: Campaign IDs Lib-->>Page: Campaigns par Fetch Totals & Freshness Page->>Lib: listMoneyTotals(...) Lib->>DB: public_campaigns DB-->>Lib: Totals Lib-->>Page: Totals Map and Page->>Lib: listCampaignStatementFreshness(ids) Lib->>DB: rpc:public_campaign_statement_freshness DB-->>Lib: Timestamps Lib-->>Page: Freshness Map end Page-->>Client: Render Cards with "Sao kê mới nhất" else Homepage Client->>Page: Request / Page->>Lib: listPublicCampaigns (newest, almost_funded, recently_audited) Lib->>DB: rpc:discover_campaigns (x3) DB-->>Lib: IDs for each strip Lib-->>Page: Campaigns Page->>Lib: listMoneyTotals & listCampaignStatementFreshness Lib->>DB: public_campaigns & rpc:public_campaign_statement_freshness DB-->>Lib: Data Lib-->>Page: Maps Page-->>Client: Render Highlight Strips end