-
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
Merged
gaspergrom
merged 10 commits into
main
from
feat/collections-v2-aggregate-pipes-IN-1193-IN-1195
Jul 14, 2026
+52
−2
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7782241
feat: add collections v2 aggregate Tinybird pipes and toggle column
gaspergrom 569d53b
fix: resolve collection_insights_aggregate via collectionsSlugs, not …
gaspergrom 2fdaf56
chore: remove unused IN-1195 aggregate pipes for now
gaspergrom 8d40eb1
feat: manage showAggregateTabs from CDP admin, default false + backfi…
gaspergrom 313b86b
chore: exclude packages_worker family from clean-start-fe-dev
gaspergrom bd5c2b1
chore: add undo migration for showAggregateTabs column
gaspergrom b2c18e1
Merge branch 'main' into feat/collections-v2-aggregate-pipes-IN-1193-…
gaspergrom d75a249
fix: address PR #4336 review comments (CM-1193)
gaspergrom 64db617
fix: make CollectionRequest.showAggregateTabs optional (CM-1193)
gaspergrom cc3b759
revert: drop showAggregateTabs column, migration, and CDP admin manag…
gaspergrom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...end/src/database/migrations/V1782500000__addShowAggregateTabsColumnToCollectionsTable.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- Add the showAggregateTabs column to the collections table | ||
| ALTER TABLE collections | ||
| ADD COLUMN "showAggregateTabs" boolean DEFAULT true NOT NULL; | ||
54 changes: 54 additions & 0 deletions
54
services/libs/tinybird/pipes/collection_contributors_leaderboard_aggregate.pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| DESCRIPTION > | ||
| - `collection_contributors_leaderboard_aggregate.pipe` serves the contributors leaderboard widget for a collection (an arbitrary list of projects). | ||
| - Returns the top 20 contributors ranked by total contribution count, aggregated/deduplicated across all projects in the list (a contributor active on multiple projects is summed once, not listed per project). | ||
| - Parameters: | ||
| - `ids`: Required array of project ids (as returned by `project_insights.pipe`'s `id`/`ids`) to aggregate over. | ||
| - Response: | ||
| - `id`: member id. | ||
| - `avatar`: member avatar URL. | ||
| - `displayName`: member display name. | ||
| - `githubHandleArray`: member's GitHub usernames. | ||
| - `contributionCount`: total contribution count for the member, summed across all matched projects. | ||
|
|
||
| TAGS "Insights, Widget", "Collection" | ||
|
|
||
| NODE collection_contributors_leaderboard_aggregate_projects | ||
| DESCRIPTION > | ||
| Resolves the input project ids to their segment ids, since activity data is keyed by segmentId, not project id | ||
|
|
||
| SQL > | ||
| % | ||
| SELECT id, segmentId | ||
| FROM project_insights_copy_ds | ||
| WHERE | ||
| type = 'project' | ||
| AND id IN {{ Array(ids, 'String', description="Filter by project id list", required=True) }} | ||
|
|
||
| NODE collection_contributors_leaderboard_aggregate_members | ||
| DESCRIPTION > | ||
| Sums contribution counts per member across the matched projects' segments | ||
|
|
||
| SQL > | ||
| SELECT ar.memberId AS memberId, count(ar.activityId) AS contributionCount | ||
| FROM activityRelations_deduplicated_cleaned_bucket_union AS ar | ||
| WHERE | ||
| ar.memberId != '' | ||
| AND ar.segmentId IN (SELECT segmentId FROM collection_contributors_leaderboard_aggregate_projects) | ||
|
gaspergrom marked this conversation as resolved.
Outdated
|
||
| GROUP BY ar.memberId | ||
| ORDER BY contributionCount DESC, memberId DESC | ||
| LIMIT 20 | ||
|
|
||
| NODE collection_contributors_leaderboard_aggregate_results | ||
| DESCRIPTION > | ||
| Joins the top members with their profile data | ||
|
|
||
| SQL > | ||
| SELECT | ||
| m.id AS id, | ||
| m.avatar AS avatar, | ||
| m.displayName AS displayName, | ||
| m.githubHandleArray AS githubHandleArray, | ||
| ma.contributionCount AS contributionCount | ||
| FROM collection_contributors_leaderboard_aggregate_members AS ma | ||
| INNER JOIN members_sorted AS m ON m.id = ma.memberId | ||
| ORDER BY contributionCount DESC, id DESC | ||
36 changes: 36 additions & 0 deletions
36
services/libs/tinybird/pipes/collection_development_aggregate.pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| DESCRIPTION > | ||
| - `collection_development_aggregate.pipe` serves aggregate development activity metrics for a collection (an arbitrary list of projects). | ||
| - Returns a single row with active contributors and active organizations aggregated across all projects in the list, deduplicated (a contributor or organization active on multiple projects in the list is counted once, not once per project), restricted to the last 365 days to mirror the per-project `activeContributorsLast365Days` / `activeOrganizationsLast365Days` semantics. | ||
| - Parameters: | ||
| - `ids`: Required array of project ids (as returned by `project_insights.pipe`'s `id`/`ids`) to aggregate over. | ||
| - Response: | ||
| - `activeContributorsLast365Days`: total unique contributors across all matched projects' segments in the last 365 days. | ||
| - `activeOrganizationsLast365Days`: total unique organizations across all matched projects' segments in the last 365 days. | ||
|
|
||
| TAGS "Insights, Widget", "Collection" | ||
|
|
||
| NODE collection_development_aggregate_projects | ||
| DESCRIPTION > | ||
| Resolves the input project ids to their segment ids, since activity data is keyed by segmentId, not project id | ||
|
|
||
| SQL > | ||
| % | ||
| SELECT id, segmentId | ||
| FROM project_insights_copy_ds | ||
| WHERE | ||
| type = 'project' | ||
| AND id IN {{ Array(ids, 'String', description="Filter by project id list", required=True) }} | ||
|
|
||
| NODE collection_development_aggregate_results | ||
| DESCRIPTION > | ||
| Counts unique contributors and unique organizations across matched projects' segments in the last 365 days | ||
|
|
||
| SQL > | ||
| SELECT | ||
| uniq(case when ar.memberId != '' then ar.memberId else null end) AS activeContributorsLast365Days, | ||
| uniq(case when ar.organizationId != '' then ar.organizationId else null end) AS activeOrganizationsLast365Days | ||
| FROM activityRelations_deduplicated_cleaned_bucket_union AS ar | ||
| WHERE | ||
| ar.segmentId IN (SELECT segmentId FROM collection_development_aggregate_projects) | ||
| AND ar.timestamp >= now() - INTERVAL 365 DAY | ||
| AND ar.timestamp < now() |
37 changes: 37 additions & 0 deletions
37
services/libs/tinybird/pipes/collection_insights_aggregate.pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| DESCRIPTION > | ||
|
joanagmaia marked this conversation as resolved.
joanagmaia marked this conversation as resolved.
|
||
| - `collection_insights_aggregate.pipe` serves aggregate insights metrics for a collection (an arbitrary list of projects). | ||
| - Returns a single row with metrics aggregated across all projects in the list, not one row per project. | ||
| - Parameters: | ||
| - `ids`: Required array of project ids (as returned by `project_insights.pipe`'s `id`/`ids`) to aggregate over. | ||
| - Response: | ||
| - `projectCount`: count of distinct project ids from the input list that matched an existing project. | ||
| - `uniqueContributorCount`: total unique contributors across all matched projects, deduplicated (a contributor active on multiple projects in the list is counted once). | ||
| - `avgHealthScore`: average of each matched project's health score, rounded. | ||
|
|
||
| TAGS "Insights, Widget", "Collection" | ||
|
|
||
| NODE collection_insights_aggregate_projects | ||
| DESCRIPTION > | ||
| Resolves the input project ids to their segment ids, since activity data is keyed by segmentId, not project id | ||
|
|
||
| SQL > | ||
| % | ||
| SELECT id, segmentId, healthScore | ||
| FROM project_insights_copy_ds | ||
| WHERE | ||
| type = 'project' | ||
| AND id IN {{ Array(ids, 'String', description="Filter by project id list", required=True) }} | ||
|
|
||
| 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.
|
||
42 changes: 42 additions & 0 deletions
42
services/libs/tinybird/pipes/collection_popularity_aggregate.pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| DESCRIPTION > | ||
| - `collection_popularity_aggregate.pipe` serves aggregate popularity metrics for a collection (an arbitrary list of projects). | ||
| - Returns a single row with stars and forks summed across all projects in the list, for both the current and previous 365-day windows, so the frontend can compute a trend delta. | ||
| - Stars and forks are not deduplication-sensitive (a star on one repo is independent of a star on another), so a plain SUM across matched projects is correct. | ||
| - Parameters: | ||
| - `ids`: Required array of project ids (as returned by `project_insights.pipe`'s `id`/`ids`) to aggregate over. | ||
| - Response: | ||
| - `totalStars`: sum of `starsLast365Days` across all matched projects. | ||
| - `totalForks`: sum of `forksLast365Days` across all matched projects. | ||
| - `starsPrevious365Days`: sum of `starsPrevious365Days` across all matched projects. | ||
| - `forksPrevious365Days`: sum of `forksPrevious365Days` across all matched projects. | ||
|
|
||
| TAGS "Insights, Widget", "Collection" | ||
|
|
||
| NODE collection_popularity_aggregate_projects | ||
| DESCRIPTION > | ||
| Resolves the input project ids to their per-project popularity fields | ||
|
|
||
| SQL > | ||
| % | ||
| SELECT | ||
| id, | ||
| starsLast365Days, | ||
| forksLast365Days, | ||
| starsPrevious365Days, | ||
| forksPrevious365Days | ||
| FROM project_insights_copy_ds | ||
| WHERE | ||
| type = 'project' | ||
| AND id IN {{ Array(ids, 'String', description="Filter by project id list", required=True) }} | ||
|
|
||
| NODE collection_popularity_aggregate_results | ||
| DESCRIPTION > | ||
| Sums stars and forks across matched projects for the current and previous 365-day windows | ||
|
|
||
| SQL > | ||
| SELECT | ||
| sum(starsLast365Days) AS totalStars, | ||
| sum(forksLast365Days) AS totalForks, | ||
| sum(starsPrevious365Days) AS starsPrevious365Days, | ||
| sum(forksPrevious365Days) AS forksPrevious365Days | ||
| FROM collection_popularity_aggregate_projects |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.