Skip to content

Commit 6561b1b

Browse files
joanagmaiaclaude
andauthored
feat: organization page tinybird pipe improvements (IN-1204) (#4359)
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f8db58f commit 6561b1b

8 files changed

Lines changed: 94 additions & 45 deletions

services/libs/tinybird/pipes/leaderboards_organizations.pipe

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ DESCRIPTION >
55

66
NODE leaderboards_organizations_data
77
DESCRIPTION >
8-
Retrieves all organizations from the populated datasource
8+
Retrieves all organizations from the populated datasource, including slug for page links
99

1010
SQL >
11-
SELECT id, displayName, logo FROM organizations FINAL
11+
SELECT o.id, o.displayName, o.logo, ops.slug
12+
FROM organizations o FINAL
13+
LEFT JOIN organizations_populated_slug ops ON o.id = ops.id
1214

1315
NODE leaderboards_organizations_activity_types
1416
DESCRIPTION >
@@ -67,7 +69,7 @@ SQL >
6769
p.id as id,
6870
'' as segmentId,
6971
p.displayName as name,
70-
'' as slug,
72+
p.slug as slug,
7173
p.logo as logoUrl,
7274
'organizations' as leaderboardType,
7375
cast(coalesce(c.organizationActivityCount, 0) as Float64) as value,
@@ -83,7 +85,8 @@ SQL >
8385
JOIN c.segmentIds as sid
8486
LEFT JOIN leaderboards_organizations_projects proj ON proj.segmentId = sid
8587
WHERE c.organizationActivityCount > 0
86-
GROUP BY p.id, p.displayName, p.logo, c.organizationActivityCount, pp.organizationActivityCount
88+
GROUP BY
89+
p.id, p.displayName, p.logo, p.slug, c.organizationActivityCount, pp.organizationActivityCount
8790
ORDER BY value DESC
8891
LIMIT 100
8992

services/libs/tinybird/pipes/org_page_activities_timeseries.pipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DESCRIPTION >
2-
Activity timeseries for a given organization, bucketed by year (all-time).
2+
Contribution timeseries for a given organization, bucketed by year (last 10 years).
33

44
TAGS "Organization page"
55

services/libs/tinybird/pipes/org_page_activities_timeseries_copy_pipe.pipe

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
DESCRIPTION >
2-
Nightly copy pipe that precomputes yearly activity counts per organization for the org page.
2+
Nightly copy pipe that precomputes yearly code contribution counts per organization for the org page.
3+
Counts only code contribution activity types (commits, PRs, code reviews).
4+
Covers the last 10 years, bucketed by year.
35
Writes one row per (organizationId, startDate) into org_page_activities_timeseries_copy_ds.
46

57
TAGS "Organization page"
68

9+
NODE org_page_activities_timeseries_code_activity_types
10+
DESCRIPTION >
11+
Code contribution activity types only
12+
13+
SQL >
14+
SELECT activityType, platform FROM activityTypes FINAL WHERE isCodeContribution
15+
716
NODE org_page_activities_timeseries_copy_pipe_data
817
SQL >
918
SELECT
10-
organizationId,
11-
toStartOfYear(timestamp) AS startDate,
12-
toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
19+
ar.organizationId,
20+
toStartOfYear(ar.timestamp) AS startDate,
21+
toDate(toStartOfYear(ar.timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
1322
count() AS activityCount,
1423
now() AS computedAt
15-
FROM activityRelations_deduplicated_cleaned_bucket_union
16-
WHERE organizationId != '' AND timestamp >= '2016-01-01'
17-
GROUP BY organizationId, startDate, endDate
24+
FROM activityRelations_deduplicated_cleaned_bucket_union ar
25+
INNER JOIN
26+
org_page_activities_timeseries_code_activity_types at
27+
ON ar.type = at.activityType
28+
AND ar.platform = at.platform
29+
WHERE ar.organizationId != '' AND ar.timestamp >= toStartOfYear(now() - toIntervalYear(10))
30+
GROUP BY ar.organizationId, startDate, endDate
1831

1932
TYPE COPY
2033
TARGET_DATASOURCE org_page_activities_timeseries_copy_ds

services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DESCRIPTION >
2-
Contributor count timeseries for a given organization, bucketed by year (all-time).
2+
Contributor count timeseries for a given organization, bucketed by year (last 10 years).
33

44
TAGS "Organization page"
55

services/libs/tinybird/pipes/org_page_contributors_timeseries_copy_pipe.pipe

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
DESCRIPTION >
22
Nightly copy pipe that precomputes yearly unique contributor counts per organization for the org page.
3+
Counts only contributors active via code contribution activity types (commits, PRs, code reviews).
4+
Covers the last 10 years, bucketed by year.
35
Writes one row per (organizationId, startDate) into org_page_contributors_timeseries_copy_ds.
46

57
TAGS "Organization page"
68

9+
NODE org_page_contributors_timeseries_code_activity_types
10+
DESCRIPTION >
11+
Code contribution activity types only
12+
13+
SQL >
14+
SELECT activityType, platform FROM activityTypes FINAL WHERE isCodeContribution
15+
716
NODE org_page_contributors_timeseries_copy_pipe_data
817
SQL >
918
SELECT
10-
organizationId,
11-
toStartOfYear(timestamp) AS startDate,
12-
toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
13-
uniq(memberId) AS contributorCount,
19+
ar.organizationId,
20+
toStartOfYear(ar.timestamp) AS startDate,
21+
toDate(toStartOfYear(ar.timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
22+
uniq(ar.memberId) AS contributorCount,
1423
now() AS computedAt
15-
FROM activityRelations_deduplicated_cleaned_bucket_union
16-
WHERE organizationId != '' AND timestamp >= '2016-01-01'
17-
GROUP BY organizationId, startDate, endDate
24+
FROM activityRelations_deduplicated_cleaned_bucket_union ar
25+
INNER JOIN
26+
org_page_contributors_timeseries_code_activity_types at
27+
ON ar.type = at.activityType
28+
AND ar.platform = at.platform
29+
WHERE ar.organizationId != '' AND ar.timestamp >= toStartOfYear(now() - toIntervalYear(10))
30+
GROUP BY ar.organizationId, startDate, endDate
1831

1932
TYPE COPY
2033
TARGET_DATASOURCE org_page_contributors_timeseries_copy_ds

services/libs/tinybird/pipes/org_page_kpis.pipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
DESCRIPTION >
22
Returns KPIs for a given organization from the precomputed org_page_kpis_copy_ds.
3-
Includes trend calculations comparing current to previous 365-day period.
3+
Includes trend calculations comparing current to previous 730-day period.
44

55
TAGS "Organization page"
66

services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,78 @@
11
DESCRIPTION >
22
Nightly copy pipe that precomputes org-level KPIs for the org page.
33
Writes one row per organizationId into org_page_kpis_copy_ds.
4+
Active contributors count only code contribution activity types (commits, PRs, code reviews).
5+
Active contributors and critical projects use a 730-day (2-year) window.
6+
Trend compares current 730-day period against the prior 730-day period (days 731–1460).
47

58
TAGS "Organization page"
69

10+
NODE org_page_kpis_code_activity_types
11+
DESCRIPTION >
12+
Code contribution activity types only
13+
14+
SQL >
15+
SELECT activityType, platform FROM activityTypes FINAL WHERE isCodeContribution
16+
717
NODE org_page_kpis_current_contributors
818
DESCRIPTION >
9-
Active contributors per org in the last 365 days
19+
Active code contributors per org in the last 730 days (2 years)
1020

1121
SQL >
12-
SELECT organizationId, uniq(memberId) AS activeContributors
13-
FROM activityRelations_deduplicated_cleaned_bucket_union
22+
SELECT ar.organizationId, uniq(ar.memberId) AS activeContributors
23+
FROM activityRelations_deduplicated_cleaned_bucket_union ar
24+
INNER JOIN
25+
org_page_kpis_code_activity_types at ON ar.type = at.activityType AND ar.platform = at.platform
1426
WHERE
15-
organizationId != ''
16-
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
17-
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
18-
GROUP BY organizationId
27+
ar.organizationId != ''
28+
AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(730))
29+
AND ar.timestamp < toStartOfDay(now() + toIntervalDay(1))
30+
GROUP BY ar.organizationId
1931

2032
NODE org_page_kpis_previous_contributors
2133
DESCRIPTION >
22-
Active contributors per org in the prior 365-day window (for trend calc)
34+
Active code contributors per org in the prior 730-day window (days 731–1460, for trend calc)
2335

2436
SQL >
25-
SELECT organizationId, uniq(memberId) AS activeContributorsPrevious
26-
FROM activityRelations_deduplicated_cleaned_bucket_union
37+
SELECT ar.organizationId, uniq(ar.memberId) AS activeContributorsPrevious
38+
FROM activityRelations_deduplicated_cleaned_bucket_union ar
39+
INNER JOIN
40+
org_page_kpis_code_activity_types at ON ar.type = at.activityType AND ar.platform = at.platform
2741
WHERE
28-
organizationId != ''
29-
AND timestamp >= toStartOfDay(now() - toIntervalDay(730))
30-
AND timestamp < toStartOfDay(now() - toIntervalDay(365))
31-
GROUP BY organizationId
42+
ar.organizationId != ''
43+
AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(1460))
44+
AND ar.timestamp < toStartOfDay(now() - toIntervalDay(730))
45+
GROUP BY ar.organizationId
3246

3347
NODE org_page_kpis_maintainer_roles
3448
DESCRIPTION >
35-
Count of active maintainer role assignments per org
49+
Count of maintainer role assignments per org active at any point in the last 730 days (2 years)
3650

3751
SQL >
3852
SELECT organizationId, uniq((memberId, insightsProjectId)) AS maintainerRoles
3953
FROM maintainers_roles_copy_ds
40-
WHERE role = 'maintainer' AND toYear(endDate) <= 1970 AND organizationId != ''
54+
WHERE
55+
role = 'maintainer'
56+
AND organizationId != ''
57+
AND startDate <= now()
58+
AND (toYear(endDate) <= 1970 OR endDate >= now() - toIntervalDay(730))
4159
GROUP BY organizationId
4260

4361
NODE org_page_kpis_critical_projects
4462
DESCRIPTION >
45-
Count of distinct projects (segmentIds) an org contributed to in the last 365 days.
63+
Count of distinct projects (segmentIds) an org made code contributions to in the last 730 days (2 years).
4664
Serves as the "critical projects" placeholder until a real criticality filter is added.
4765

4866
SQL >
49-
SELECT organizationId, uniq(segmentId) AS criticalProjects
50-
FROM activityRelations_deduplicated_cleaned_bucket_union
67+
SELECT ar.organizationId, uniq(ar.segmentId) AS criticalProjects
68+
FROM activityRelations_deduplicated_cleaned_bucket_union ar
69+
INNER JOIN
70+
org_page_kpis_code_activity_types at ON ar.type = at.activityType AND ar.platform = at.platform
5171
WHERE
52-
organizationId != ''
53-
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
54-
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
55-
GROUP BY organizationId
72+
ar.organizationId != ''
73+
AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(730))
74+
AND ar.timestamp < toStartOfDay(now() + toIntervalDay(1))
75+
GROUP BY ar.organizationId
5676

5777
NODE org_page_kpis_final
5878
DESCRIPTION >

services/libs/tinybird/pipes/org_page_projects.pipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ SQL >
3030
technicalScore
3131
FROM org_page_projects_copy_ds FINAL
3232
WHERE organizationId = (SELECT id FROM org_slug_lookup)
33-
ORDER BY technicalScore DESC, contributorCount DESC, activityCount DESC
33+
ORDER BY contributorCount DESC, technicalScore DESC, activityCount DESC
3434
LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }}
3535
OFFSET {{ Int32(offset, 0, description="Pagination offset") }}

0 commit comments

Comments
 (0)