Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment thread
gaspergrom marked this conversation as resolved.
Outdated
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)
Comment thread
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 services/libs/tinybird/pipes/collection_development_aggregate.pipe
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 services/libs/tinybird/pipes/collection_insights_aggregate.pipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
DESCRIPTION >
Comment thread
joanagmaia marked this conversation as resolved.
Comment thread
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)
Comment thread
gaspergrom marked this conversation as resolved.
Comment thread
gaspergrom marked this conversation as resolved.
Comment thread
gaspergrom marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
gaspergrom marked this conversation as resolved.
42 changes: 42 additions & 0 deletions services/libs/tinybird/pipes/collection_popularity_aggregate.pipe
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
Loading