fix: include community collections in collectionsSlugs (IN-1195)#4360
Conversation
collection_insights_aggregate reported 0 contributors and no health score for community (non-LF) collections because insights_projects_populated_copy excluded them via isNull(c.ssoUserId) when building collectionsSlugs. Drop that filter so community collection memberships are populated too. Downstream leaderboard and insightsProjects_filtered pipes only apply the collectionsSlugs filter when an explicit collectionSlug param is passed, so un-scoped listings are unaffected. Claude-Session: https://claude.ai/code/session_014Fc86j8FLeWFAs3fDCQs38 Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
PR SummaryLow Risk Overview The Downstream pipes only filter on Reviewed by Cursor Bugbot for commit 49f1949. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Updates Tinybird collection membership so public community collections receive contributor and health metrics.
Changes:
- Removes the curated-only collection filter.
- Documents downstream impact.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| FROM collectionsInsightsProjects cip FINAL | ||
| JOIN collections c FINAL ON c.id = cip.collectionId | ||
| WHERE isNull (c.deletedAt) AND isNull (c.ssoUserId) AND isNull (cip.deletedAt) | ||
| WHERE isNull (c.deletedAt) AND isNull (cip.deletedAt) |
Problem
Community (non-LF) collection detail pages show Contributors: 0 and Avg. Health: — even when the collection has projects (e.g.
agentic-ai-momentum-watchlistshows 88 projects but 0 contributors). Reported from a review of the Collections feature.Root cause is in the Tinybird layer, not the frontend. The
collection_insights_aggregatepipe (which powers the header metrics) resolves collection membership viainsights_projects_populated_ds.collectionsSlugs. That array is built ininsights_projects_populated_copy.pipe, whosecollectionsSlugsnode filtered withAND isNull(c.ssoUserId)—ssoUserIdis set for community/user-created collections and null only for curated (LF) ones. So every community collection was excluded fromcollectionsSlugs, and the aggregate pipe matched 0 projects for them →uniqueContributorCount: 0,avgHealthScore: nan. The Postgres-derived project count still worked, which is why the count showed but the other two metrics didn't.Verified against prod Tinybird:
cloud-native-computing-foundation-(cncf)(curated) → 127 / 306251 / 72 ✅agentic-ai-momentum-watchlist(community) → 0 / 0 / nan ❌arrayJoin(collectionsSlugs)contains no community slugs (only curated).Fix
Drop the
AND isNull(c.ssoUserId)filter from thecollectionsSlugsnode so community collection memberships are populated alongside curated ones.Blast radius
Other consumers of
collectionsSlugs(collection_insights_aggregate,segments_filtered_by_collection,leaderboards_*,insightsProjects_filtered) only apply acollectionsSlugsfilter when an explicitcollectionSlugparam is passed — so no un-scoped listing changes. The only new capability is that passing a communitycollectionSlugnow returns results, which is the intended behavior.insights_projects_populated_copyis aCOPYpipe on a*/15 * * * *schedule, so the 43 existing community collections will backfill correct metrics on the next run after deploy — no manual backfill needed.Validation
tb checkpassestb fmtappliedcollectionsSlugscolumn unchanged (only more rows populated)Related
Frontend collection-widget wiring (Contributors/Popularity/Development tabs) is tracked separately in insights PR #2013 (IN-1191). This PR is the upstream data half and is independent of it.
https://claude.ai/code/session_014Fc86j8FLeWFAs3fDCQs38