Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 7 additions & 4 deletions services/libs/tinybird/pipes/leaderboards_organizations.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ DESCRIPTION >

NODE leaderboards_organizations_data
DESCRIPTION >
Retrieves all organizations from the populated datasource
Retrieves all organizations from the populated datasource, including slug for page links

SQL >
SELECT id, displayName, logo FROM organizations FINAL
SELECT o.id, o.displayName, o.logo, ops.slug
FROM organizations o FINAL
LEFT JOIN organizations_populated_slug ops ON o.id = ops.id
Comment thread
joanagmaia marked this conversation as resolved.

NODE leaderboards_organizations_activity_types
DESCRIPTION >
Expand Down Expand Up @@ -67,7 +69,7 @@ SQL >
p.id as id,
'' as segmentId,
p.displayName as name,
'' as slug,
p.slug as slug,
p.logo as logoUrl,
'organizations' as leaderboardType,
cast(coalesce(c.organizationActivityCount, 0) as Float64) as value,
Expand All @@ -83,7 +85,8 @@ SQL >
JOIN c.segmentIds as sid
LEFT JOIN leaderboards_organizations_projects proj ON proj.segmentId = sid
WHERE c.organizationActivityCount > 0
GROUP BY p.id, p.displayName, p.logo, c.organizationActivityCount, pp.organizationActivityCount
GROUP BY
p.id, p.displayName, p.logo, p.slug, c.organizationActivityCount, pp.organizationActivityCount
ORDER BY value DESC
LIMIT 100

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DESCRIPTION >
Activity timeseries for a given organization, bucketed by year (all-time).
Contribution timeseries for a given organization, bucketed by year (last 10 years).
Comment thread
joanagmaia marked this conversation as resolved.

TAGS "Organization page"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
DESCRIPTION >
Nightly copy pipe that precomputes yearly activity counts per organization for the org page.
Nightly copy pipe that precomputes yearly code contribution counts per organization for the org page.
Counts only code contribution activity types (commits, PRs, code reviews).
Covers the last 10 years, bucketed by year.
Writes one row per (organizationId, startDate) into org_page_activities_timeseries_copy_ds.

TAGS "Organization page"

NODE org_page_activities_timeseries_code_activity_types
DESCRIPTION >
Code contribution activity types only

SQL >
SELECT activityType, platform FROM activityTypes FINAL WHERE isCodeContribution

NODE org_page_activities_timeseries_copy_pipe_data
SQL >
SELECT
organizationId,
toStartOfYear(timestamp) AS startDate,
toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
ar.organizationId,
toStartOfYear(ar.timestamp) AS startDate,
toDate(toStartOfYear(ar.timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
count() AS activityCount,
now() AS computedAt
FROM activityRelations_deduplicated_cleaned_bucket_union
WHERE organizationId != '' AND timestamp >= '2016-01-01'
GROUP BY organizationId, startDate, endDate
FROM activityRelations_deduplicated_cleaned_bucket_union ar
INNER JOIN
org_page_activities_timeseries_code_activity_types at
ON ar.type = at.activityType
AND ar.platform = at.platform
Comment thread
joanagmaia marked this conversation as resolved.
WHERE ar.organizationId != '' AND ar.timestamp >= toStartOfYear(now() - toIntervalYear(10))
Comment thread
joanagmaia marked this conversation as resolved.
Comment thread
joanagmaia marked this conversation as resolved.
GROUP BY ar.organizationId, startDate, endDate

TYPE COPY
TARGET_DATASOURCE org_page_activities_timeseries_copy_ds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DESCRIPTION >
Contributor count timeseries for a given organization, bucketed by year (all-time).
Contributor count timeseries for a given organization, bucketed by year (last 10 years).

TAGS "Organization page"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
DESCRIPTION >
Nightly copy pipe that precomputes yearly unique contributor counts per organization for the org page.
Counts only contributors active via code contribution activity types (commits, PRs, code reviews).
Covers the last 10 years, bucketed by year.
Writes one row per (organizationId, startDate) into org_page_contributors_timeseries_copy_ds.

TAGS "Organization page"

NODE org_page_contributors_timeseries_code_activity_types
DESCRIPTION >
Code contribution activity types only

SQL >
SELECT activityType, platform FROM activityTypes FINAL WHERE isCodeContribution

NODE org_page_contributors_timeseries_copy_pipe_data
SQL >
SELECT
organizationId,
toStartOfYear(timestamp) AS startDate,
toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
uniq(memberId) AS contributorCount,
ar.organizationId,
toStartOfYear(ar.timestamp) AS startDate,
toDate(toStartOfYear(ar.timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate,
uniq(ar.memberId) AS contributorCount,
now() AS computedAt
FROM activityRelations_deduplicated_cleaned_bucket_union
WHERE organizationId != '' AND timestamp >= '2016-01-01'
GROUP BY organizationId, startDate, endDate
FROM activityRelations_deduplicated_cleaned_bucket_union ar
INNER JOIN
org_page_contributors_timeseries_code_activity_types at
ON ar.type = at.activityType
AND ar.platform = at.platform
Comment thread
joanagmaia marked this conversation as resolved.
WHERE ar.organizationId != '' AND ar.timestamp >= toStartOfYear(now() - toIntervalYear(10))
Comment thread
joanagmaia marked this conversation as resolved.
Comment thread
joanagmaia marked this conversation as resolved.
GROUP BY ar.organizationId, startDate, endDate

TYPE COPY
TARGET_DATASOURCE org_page_contributors_timeseries_copy_ds
Expand Down
2 changes: 1 addition & 1 deletion services/libs/tinybird/pipes/org_page_kpis.pipe
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DESCRIPTION >
Returns KPIs for a given organization from the precomputed org_page_kpis_copy_ds.
Includes trend calculations comparing current to previous 365-day period.
Includes trend calculations comparing current to previous 730-day period.

TAGS "Organization page"

Expand Down
66 changes: 43 additions & 23 deletions services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe
Original file line number Diff line number Diff line change
@@ -1,58 +1,78 @@
DESCRIPTION >
Nightly copy pipe that precomputes org-level KPIs for the org page.
Writes one row per organizationId into org_page_kpis_copy_ds.
Active contributors count only code contribution activity types (commits, PRs, code reviews).
Active contributors and critical projects use a 730-day (2-year) window.
Trend compares current 730-day period against the prior 730-day period (days 731–1460).
Comment thread
joanagmaia marked this conversation as resolved.

TAGS "Organization page"

NODE org_page_kpis_code_activity_types
DESCRIPTION >
Code contribution activity types only

SQL >
SELECT activityType, platform FROM activityTypes FINAL WHERE isCodeContribution

NODE org_page_kpis_current_contributors
DESCRIPTION >
Active contributors per org in the last 365 days
Active code contributors per org in the last 730 days (2 years)

SQL >
SELECT organizationId, uniq(memberId) AS activeContributors
FROM activityRelations_deduplicated_cleaned_bucket_union
SELECT ar.organizationId, uniq(ar.memberId) AS activeContributors
FROM activityRelations_deduplicated_cleaned_bucket_union ar
INNER JOIN
org_page_kpis_code_activity_types at ON ar.type = at.activityType AND ar.platform = at.platform
WHERE
organizationId != ''
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
GROUP BY organizationId
ar.organizationId != ''
AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(730))
AND ar.timestamp < toStartOfDay(now() + toIntervalDay(1))
Comment thread
joanagmaia marked this conversation as resolved.
Comment thread
joanagmaia marked this conversation as resolved.
GROUP BY ar.organizationId

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

SQL >
SELECT organizationId, uniq(memberId) AS activeContributorsPrevious
FROM activityRelations_deduplicated_cleaned_bucket_union
SELECT ar.organizationId, uniq(ar.memberId) AS activeContributorsPrevious
FROM activityRelations_deduplicated_cleaned_bucket_union ar
INNER JOIN
org_page_kpis_code_activity_types at ON ar.type = at.activityType AND ar.platform = at.platform
WHERE
organizationId != ''
AND timestamp >= toStartOfDay(now() - toIntervalDay(730))
AND timestamp < toStartOfDay(now() - toIntervalDay(365))
GROUP BY organizationId
ar.organizationId != ''
AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(1460))
AND ar.timestamp < toStartOfDay(now() - toIntervalDay(730))
GROUP BY ar.organizationId

NODE org_page_kpis_maintainer_roles
DESCRIPTION >
Count of active maintainer role assignments per org
Count of maintainer role assignments per org active at any point in the last 730 days (2 years)

SQL >
SELECT organizationId, uniq((memberId, insightsProjectId)) AS maintainerRoles
FROM maintainers_roles_copy_ds
WHERE role = 'maintainer' AND toYear(endDate) <= 1970 AND organizationId != ''
WHERE
role = 'maintainer'
AND organizationId != ''
AND startDate <= now()
AND (toYear(endDate) <= 1970 OR endDate >= now() - toIntervalDay(730))
GROUP BY organizationId

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

SQL >
SELECT organizationId, uniq(segmentId) AS criticalProjects
FROM activityRelations_deduplicated_cleaned_bucket_union
SELECT ar.organizationId, uniq(ar.segmentId) AS criticalProjects
FROM activityRelations_deduplicated_cleaned_bucket_union ar
INNER JOIN
org_page_kpis_code_activity_types at ON ar.type = at.activityType AND ar.platform = at.platform
Comment thread
joanagmaia marked this conversation as resolved.
WHERE
organizationId != ''
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
GROUP BY organizationId
ar.organizationId != ''
AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(730))
AND ar.timestamp < toStartOfDay(now() + toIntervalDay(1))
GROUP BY ar.organizationId

NODE org_page_kpis_final
DESCRIPTION >
Expand Down
2 changes: 1 addition & 1 deletion services/libs/tinybird/pipes/org_page_projects.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ SQL >
technicalScore
FROM org_page_projects_copy_ds FINAL
WHERE organizationId = (SELECT id FROM org_slug_lookup)
ORDER BY technicalScore DESC, contributorCount DESC, activityCount DESC
ORDER BY contributorCount DESC, technicalScore DESC, activityCount DESC
Comment thread
joanagmaia marked this conversation as resolved.
LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }}
OFFSET {{ Int32(offset, 0, description="Pagination offset") }}
Loading