diff --git a/services/libs/tinybird/pipes/leaderboards_organizations.pipe b/services/libs/tinybird/pipes/leaderboards_organizations.pipe index 70c23910a9..8c8a275a93 100644 --- a/services/libs/tinybird/pipes/leaderboards_organizations.pipe +++ b/services/libs/tinybird/pipes/leaderboards_organizations.pipe @@ -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 NODE leaderboards_organizations_activity_types DESCRIPTION > @@ -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, @@ -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 diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe index 45e8644268..5cc70a885b 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -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). TAGS "Organization page" diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries_copy_pipe.pipe index ec4fb4c61a..47baf68789 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries_copy_pipe.pipe @@ -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 + WHERE ar.organizationId != '' AND ar.timestamp >= toStartOfYear(now() - toIntervalYear(10)) + GROUP BY ar.organizationId, startDate, endDate TYPE COPY TARGET_DATASOURCE org_page_activities_timeseries_copy_ds diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe index 684edb208d..f69fbb48a6 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -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" diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries_copy_pipe.pipe index 2d594cc229..5d2e8e3abb 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries_copy_pipe.pipe @@ -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 + WHERE ar.organizationId != '' AND ar.timestamp >= toStartOfYear(now() - toIntervalYear(10)) + GROUP BY ar.organizationId, startDate, endDate TYPE COPY TARGET_DATASOURCE org_page_contributors_timeseries_copy_ds diff --git a/services/libs/tinybird/pipes/org_page_kpis.pipe b/services/libs/tinybird/pipes/org_page_kpis.pipe index b28bdb973b..78cd009561 100644 --- a/services/libs/tinybird/pipes/org_page_kpis.pipe +++ b/services/libs/tinybird/pipes/org_page_kpis.pipe @@ -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" diff --git a/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe index 2424dcf6a2..2ad9af6c6a 100644 --- a/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe @@ -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). 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)) + 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 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 > diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index 72994c47e6..8f89a177bd 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -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 LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }} OFFSET {{ Int32(offset, 0, description="Pagination offset") }}