-
Notifications
You must be signed in to change notification settings - Fork 730
feat: collections v2 aggregate Tinybird pipes and toggle column (IN-1193) #4336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
7782241
569d53b
2fdaf56
8d40eb1
313b86b
bd5c2b1
b2c18e1
d75a249
64db617
cc3b759
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- Add the showAggregateTabs column to the collections table, defaulting to false. | ||
| ALTER TABLE collections | ||
| ADD COLUMN "showAggregateTabs" boolean DEFAULT false NOT NULL; | ||
|
|
||
|
|
||
| -- Only LF Foundation (curated) collections get the in-depth aggregate tabs by default. | ||
| -- ssoUserId is only set for community/user-curated collections (see V1772438175), so | ||
| -- ssoUserId IS NULL identifies curated collections. | ||
| UPDATE collections | ||
| SET "showAggregateTabs" = true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this column? Can't we simply infer this from wether or not ssoUserId is null? |
||
| WHERE "ssoUserId" IS NULL; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| DESCRIPTION > | ||
|
joanagmaia marked this conversation as resolved.
joanagmaia marked this conversation as resolved.
|
||
| - `collection_insights_aggregate.pipe` serves aggregate insights metrics for a collection. | ||
| - Returns a single row with metrics aggregated across every project in the collection, not one row per project. | ||
| - Parameters: | ||
| - `collectionSlug`: Required collection slug. insights_projects_populated_ds.collectionsSlugs already lists | ||
| every collection each project belongs to (see insightsProjects_filtered.pipe for the same filter pattern), | ||
| so this pipe resolves collection membership directly rather than requiring the caller to first look up a | ||
| project id list. | ||
| - Response: | ||
| - `projectCount`: count of distinct projects in the collection. | ||
| - `uniqueContributorCount`: total unique contributors across all projects in the collection, deduplicated (a contributor active on multiple projects in the collection is counted once). | ||
| - `avgHealthScore`: average of each project's health score in the collection, rounded. | ||
|
|
||
| TAGS "Insights, Widget", "Collection" | ||
|
|
||
| NODE collection_insights_aggregate_projects | ||
| DESCRIPTION > | ||
| Resolves the collection's member projects to their segment ids and health scores directly via | ||
| collectionsSlugs, matching the same has(collectionsSlugs, ...) filter already used by | ||
| insightsProjects_filtered.pipe. | ||
|
|
||
| SQL > | ||
| % | ||
| SELECT id, segmentId, healthScore | ||
| FROM insights_projects_populated_ds | ||
| WHERE | ||
| enabled = 1 | ||
| AND has( | ||
| collectionsSlugs, | ||
| {{ String(collectionSlug, description="Filter by collection slug", required=True) }} | ||
|
joanagmaia marked this conversation as resolved.
|
||
| ) | ||
|
joanagmaia marked this conversation as resolved.
joanagmaia marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing empty segmentId filterMedium Severity The projects node does not exclude rows where Reviewed by Cursor Bugbot for commit cc3b759. Configure here. |
||
|
|
||
| NODE collection_insights_aggregate_results | ||
| DESCRIPTION > | ||
| Aggregates health score across matched projects and counts unique contributors across their segments in one pass | ||
|
|
||
| SQL > | ||
| SELECT | ||
| (SELECT count(distinct id) FROM collection_insights_aggregate_projects) AS projectCount, | ||
| uniq(ar.memberId) AS uniqueContributorCount, | ||
| (SELECT round(avg(healthScore)) FROM collection_insights_aggregate_projects) AS avgHealthScore | ||
| FROM activityRelations_deduplicated_cleaned_bucket_union AS ar | ||
| WHERE | ||
| ar.memberId != '' | ||
| AND ar.segmentId IN (SELECT segmentId FROM collection_insights_aggregate_projects) | ||
|
gaspergrom marked this conversation as resolved.
gaspergrom marked this conversation as resolved.
gaspergrom marked this conversation as resolved.
cursor[bot] marked this conversation as resolved.
gaspergrom marked this conversation as resolved.
|
||


Uh oh!
There was an error while loading. Please reload this page.