From 8176752adf34130f3fbe580b95963226b3eda3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Mon, 18 May 2026 16:49:30 +0100 Subject: [PATCH 01/15] feat: add tinybird pipes for organization page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../org_page_kpis_copy_ds.datasource | 15 +++ .../org_page_projects_copy_ds.datasource | 17 +++ .../pipes/org_page_activities_timeseries.pipe | 115 ++++++++++++++++++ .../tinybird/pipes/org_page_contributors.pipe | 67 ++++++++++ .../org_page_contributors_timeseries.pipe | 115 ++++++++++++++++++ .../libs/tinybird/pipes/org_page_kpis.pipe | 24 ++++ .../pipes/org_page_kpis_copy_pipe.pipe | 80 ++++++++++++ .../libs/tinybird/pipes/org_page_profile.pipe | 43 +++++++ .../tinybird/pipes/org_page_projects.pipe | 17 +++ .../pipes/org_page_projects_copy_pipe.pipe | 41 +++++++ 10 files changed, 534 insertions(+) create mode 100644 services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource create mode 100644 services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource create mode 100644 services/libs/tinybird/pipes/org_page_activities_timeseries.pipe create mode 100644 services/libs/tinybird/pipes/org_page_contributors.pipe create mode 100644 services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe create mode 100644 services/libs/tinybird/pipes/org_page_kpis.pipe create mode 100644 services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe create mode 100644 services/libs/tinybird/pipes/org_page_profile.pipe create mode 100644 services/libs/tinybird/pipes/org_page_projects.pipe create mode 100644 services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe diff --git a/services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource new file mode 100644 index 0000000000..caf8a91668 --- /dev/null +++ b/services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource @@ -0,0 +1,15 @@ +DESCRIPTION > + Precomputed organization-level KPIs for the org page. Rebuilt nightly by org_page_kpis_copy_pipe. + One row per organizationId. Used by org_page_kpis.pipe for cheap request-time lookups. + +SCHEMA > + `organizationId` String, + `activeContributors` UInt32, + `activeContributorsPrevious` UInt32, + `maintainerRoles` UInt32, + `criticalProjects` UInt32, + `computedAt` DateTime + +ENGINE ReplacingMergeTree +ENGINE_SORTING_KEY organizationId +ENGINE_VER computedAt diff --git a/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource new file mode 100644 index 0000000000..a0bc378bc1 --- /dev/null +++ b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource @@ -0,0 +1,17 @@ +DESCRIPTION > + Precomputed per-org per-project metrics for the org page. Rebuilt nightly by org_page_projects_copy_pipe. + One row per (organizationId, segmentId). Used by org_page_projects.pipe. + +SCHEMA > + `organizationId` String, + `segmentId` String, + `projectSlug` String, + `projectName` String, + `projectLogo` String, + `activityCount` UInt64, + `contributorCount` UInt32, + `computedAt` DateTime + +ENGINE ReplacingMergeTree +ENGINE_SORTING_KEY organizationId, segmentId +ENGINE_VER computedAt diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe new file mode 100644 index 0000000000..0929bf0975 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -0,0 +1,115 @@ +DESCRIPTION > + Activity timeseries for a given organization, bucketed by granularity. + Filters to activities where the member belongs to the given org. + +TAGS "Organization page" + +NODE org_page_activities_bounds +SQL > + % + SELECT min(timestamp) AS actual_start_date, max(timestamp) AS actual_end_date + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + {% if defined(startDate) %} + AND timestamp >= {{ DateTime(startDate, description="Filter activity timestamp after") }} + {% end %} + {% if defined(endDate) %} + AND timestamp < {{ DateTime(endDate, description="Filter activity timestamp before") }} + {% end %} + +NODE org_page_activities_timeseries_data +SQL > + % + SELECT + CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(addDays(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) + END AS startDate, + CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(addDays(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN + toDate( + toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) + + INTERVAL 6 DAY + ) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN + toDate( + toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) + + INTERVAL 1 MONTH + - INTERVAL 1 DAY + ) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN + toDate( + toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) + + INTERVAL 3 MONTH + - INTERVAL 1 DAY + ) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN + toDate( + toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) + + INTERVAL 1 YEAR + - INTERVAL 1 DAY + ) + END AS endDate, + count() AS activityCount + FROM numbers(1000) numbers + CROSS JOIN + ( + SELECT + CASE + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(actual_start_date) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(actual_start_date) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(actual_start_date) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(actual_start_date) + ELSE actual_start_date + END AS actual_start_date, + actual_end_date + FROM org_page_activities_bounds + ) bounds + LEFT JOIN + activityRelations_deduplicated_cleaned_bucket_union af + ON organizationId = {{ String(orgId, '') }} + AND CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(af.timestamp) + END = CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(addDays(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) + END + WHERE startDate >= bounds.actual_start_date AND startDate < bounds.actual_end_date + GROUP BY startDate, endDate + ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_contributors.pipe b/services/libs/tinybird/pipes/org_page_contributors.pipe new file mode 100644 index 0000000000..c5cd90d428 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_contributors.pipe @@ -0,0 +1,67 @@ +DESCRIPTION > + Top contributors for a given organization leaderboard. + Returns members sorted by contribution count within the specified date range. + +TAGS "Organization page" + +NODE org_page_contributors_activity_aggregates +SQL > + % + {% if Boolean(count, false) %} + SELECT count(distinct memberId) + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + {% if defined(startDate) %} + AND timestamp + >= {{ DateTime(startDate, description="Filter activity timestamp after") }} + {% end %} + {% if defined(endDate) %} + AND timestamp < {{ DateTime(endDate, description="Filter activity timestamp before") }} + {% end %} + {% else %} + SELECT + memberId, + count() as "contributionCount", + ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (), 2) as "contributionPercentage" + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + {% if defined(startDate) %} + AND timestamp + >= {{ DateTime(startDate, description="Filter activity timestamp after") }} + {% end %} + {% if defined(endDate) %} + AND timestamp < {{ DateTime(endDate, description="Filter activity timestamp before") }} + {% end %} + GROUP BY memberId + ORDER BY contributionCount DESC, memberId DESC + LIMIT {{ Int32(limit, 10) }} + OFFSET {{ Int32(offset, 0) }} + {% end %} + +NODE org_page_contributors_leaderboard +SQL > + % + {% if Boolean(count, false) %} + SELECT count(distinct memberId) as count + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId = {{ String(orgId, '') }} + {% if defined(startDate) %} AND timestamp >= {{ DateTime(startDate) }} {% end %} + {% if defined(endDate) %} AND timestamp < {{ DateTime(endDate) }} {% end %} + {% else %} + SELECT + m.id, + m.avatar, + m.displayName, + m.githubHandleArray, + agg.contributionCount, + agg.contributionPercentage, + mr.roles + FROM members_sorted AS m ANY + INNER JOIN org_page_contributors_activity_aggregates agg ON agg.memberId = m.id + LEFT JOIN member_roles mr ON mr.memberId = m.id + WHERE m.id IN (SELECT memberId FROM org_page_contributors_activity_aggregates) + ORDER BY agg.contributionCount DESC + {% end %} diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe new file mode 100644 index 0000000000..821450be94 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -0,0 +1,115 @@ +DESCRIPTION > + Contributor count timeseries for a given organization, bucketed by granularity. + Filters to activities where the member belongs to the given org. + +TAGS "Organization page" + +NODE org_page_contributors_bounds +SQL > + % + SELECT min(timestamp) AS actual_start_date, max(timestamp) AS actual_end_date + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + {% if defined(startDate) %} + AND timestamp >= {{ DateTime(startDate, description="Filter activity timestamp after") }} + {% end %} + {% if defined(endDate) %} + AND timestamp < {{ DateTime(endDate, description="Filter activity timestamp before") }} + {% end %} + +NODE org_page_contributors_timeseries_data +SQL > + % + SELECT + CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(addDays(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) + END AS startDate, + CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(addDays(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN + toDate( + toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) + + INTERVAL 6 DAY + ) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN + toDate( + toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) + + INTERVAL 1 MONTH + - INTERVAL 1 DAY + ) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN + toDate( + toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) + + INTERVAL 3 MONTH + - INTERVAL 1 DAY + ) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN + toDate( + toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) + + INTERVAL 1 YEAR + - INTERVAL 1 DAY + ) + END AS endDate, + uniqExact(af.memberId) AS contributorCount + FROM numbers(1000) numbers + CROSS JOIN + ( + SELECT + CASE + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(actual_start_date) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(actual_start_date) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(actual_start_date) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(actual_start_date) + ELSE actual_start_date + END AS actual_start_date, + actual_end_date + FROM org_page_contributors_bounds + ) bounds + LEFT JOIN + activityRelations_deduplicated_cleaned_bucket_union af + ON organizationId = {{ String(orgId, '') }} + AND CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(af.timestamp) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(af.timestamp) + END = CASE + WHEN {{ String(granularity, 'monthly') }} = 'daily' + THEN toDate(addDays(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'weekly' + THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) + WHEN {{ String(granularity, 'monthly') }} = 'monthly' + THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) + WHEN {{ String(granularity, 'monthly') }} = 'quarterly' + THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) + WHEN {{ String(granularity, 'monthly') }} = 'yearly' + THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) + END + WHERE startDate >= bounds.actual_start_date AND startDate < bounds.actual_end_date + GROUP BY startDate, endDate + ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_kpis.pipe b/services/libs/tinybird/pipes/org_page_kpis.pipe new file mode 100644 index 0000000000..e7cc43f13d --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_kpis.pipe @@ -0,0 +1,24 @@ +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. + +TAGS "Organization page" + +NODE org_page_kpis_main +SQL > + SELECT + activeContributors, + if( + activeContributorsPrevious = 0, 0, + round( + (toInt64(activeContributors) - toInt64(activeContributorsPrevious)) + / activeContributorsPrevious * 100, + 1 + ) + ) AS activeContributorsTrend, + toInt64(activeContributors) - toInt64(activeContributorsPrevious) AS activeContributorsTrendAbsolute, + activeContributorsPrevious AS activeContributorsTrendPrevious, + maintainerRoles, + criticalProjects + FROM org_page_kpis_copy_ds FINAL + WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} diff --git a/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe new file mode 100644 index 0000000000..ee360f7f35 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe @@ -0,0 +1,80 @@ +DESCRIPTION > + Nightly copy pipe that precomputes org-level KPIs for the org page. + Writes one row per organizationId into org_page_kpis_copy_ds. + +TAGS "Organization page" + +NODE org_page_kpis_current_contributors +DESCRIPTION > + Active contributors per org in the last 365 days + +SQL > + SELECT organizationId, uniq(memberId) AS activeContributors + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId != '' + AND timestamp >= toStartOfDay(now() - toIntervalDay(365)) + AND timestamp < toStartOfDay(now() + toIntervalDay(1)) + GROUP BY organizationId + +NODE org_page_kpis_previous_contributors +DESCRIPTION > + Active contributors per org in the prior 365-day window (for trend calc) + +SQL > + SELECT organizationId, uniq(memberId) AS activeContributorsPrevious + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId != '' + AND timestamp >= toStartOfDay(now() - toIntervalDay(730)) + AND timestamp < toStartOfDay(now() - toIntervalDay(365)) + GROUP BY organizationId + +NODE org_page_kpis_maintainer_roles +DESCRIPTION > + Count of active maintainer role assignments per org + +SQL > + SELECT organizationId, uniq((memberId, insightsProjectId)) AS maintainerRoles + FROM maintainers_roles_copy_ds + WHERE role = 'maintainer' AND toYear(endDate) <= 1970 AND organizationId != '' + GROUP BY organizationId + +NODE org_page_kpis_critical_projects +DESCRIPTION > + Count of distinct projects (segmentIds) an org contributed to in the last 365 days. + 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 + WHERE + organizationId != '' + AND timestamp >= toStartOfDay(now() - toIntervalDay(365)) + AND timestamp < toStartOfDay(now() + toIntervalDay(1)) + GROUP BY organizationId + +NODE org_page_kpis_final +DESCRIPTION > + Join all nodes into one row per org + +SQL > + SELECT + coalesce( + c.organizationId, p.organizationId, m.organizationId, cp.organizationId + ) AS organizationId, + coalesce(c.activeContributors, 0) AS activeContributors, + coalesce(p.activeContributorsPrevious, 0) AS activeContributorsPrevious, + coalesce(m.maintainerRoles, 0) AS maintainerRoles, + coalesce(cp.criticalProjects, 0) AS criticalProjects, + now() AS computedAt + FROM org_page_kpis_current_contributors c + FULL OUTER JOIN org_page_kpis_previous_contributors p ON c.organizationId = p.organizationId + FULL OUTER JOIN org_page_kpis_maintainer_roles m ON c.organizationId = m.organizationId + FULL OUTER JOIN org_page_kpis_critical_projects cp ON c.organizationId = cp.organizationId + WHERE organizationId != '' + +TYPE COPY +TARGET_DATASOURCE org_page_kpis_copy_ds +COPY_MODE replace +COPY_SCHEDULE 15 1 * * * diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe new file mode 100644 index 0000000000..d65ec0eb72 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -0,0 +1,43 @@ +DESCRIPTION > + Organization profile for the org page. Returns one row for a given orgId. + Joins organizationIdentities for website and domain. + +TAGS "Organization page" + +NODE org_page_profile_base +SQL > + SELECT + id, + displayName, + logo, + employees AS employeeCount, + industry, + headline AS description + FROM organizations FINAL + WHERE id = {{ String(orgId, '', description="Organization ID", required=True) }} + +NODE org_page_profile_website +SQL > + SELECT + organizationId, + argMax(value, updatedAt) AS website + FROM organizationIdentities FINAL + WHERE + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + AND platform = 'website' + AND type = 'primary' + GROUP BY organizationId + +NODE org_page_profile_final +SQL > + SELECT + b.id, + b.displayName, + b.logo, + b.employeeCount, + b.industry, + b.description, + w.website, + domain(w.website) AS domain + FROM org_page_profile_base b + LEFT JOIN org_page_profile_website w ON b.id = w.organizationId diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe new file mode 100644 index 0000000000..4ca92f95c5 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -0,0 +1,17 @@ +DESCRIPTION > + Returns the list of projects an organization contributed to in the last 365 days, + read from the precomputed org_page_projects_copy_ds. + +TAGS "Organization page" + +NODE org_page_projects_main +SQL > + SELECT + projectSlug, + projectName, + projectLogo, + activityCount, + contributorCount + FROM org_page_projects_copy_ds FINAL + WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + ORDER BY activityCount DESC diff --git a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe new file mode 100644 index 0000000000..c038f348c2 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe @@ -0,0 +1,41 @@ +DESCRIPTION > + Nightly copy pipe that precomputes per-org per-project metrics for the org page. + Writes one row per (organizationId, segmentId) into org_page_projects_copy_ds. + +TAGS "Organization page" + +NODE org_page_projects_org_segment_activity +DESCRIPTION > + Activity and contributor counts per org per project segment in the last 365 days + +SQL > + SELECT organizationId, segmentId, count() AS activityCount, uniq(memberId) AS contributorCount + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId != '' + AND timestamp >= toStartOfDay(now() - toIntervalDay(365)) + AND timestamp < toStartOfDay(now() + toIntervalDay(1)) + GROUP BY organizationId, segmentId + +NODE org_page_projects_with_meta +DESCRIPTION > + Enrich with project name, logo and slug from insights_projects_populated_ds + +SQL > + SELECT + a.organizationId, + a.segmentId, + p.slug AS projectSlug, + p.name AS projectName, + p.logoUrl AS projectLogo, + a.activityCount, + a.contributorCount, + now() AS computedAt + FROM org_page_projects_org_segment_activity a + LEFT JOIN insights_projects_populated_ds p ON a.segmentId = p.segmentId + WHERE p.slug != '' + +TYPE COPY +TARGET_DATASOURCE org_page_projects_copy_ds +COPY_MODE replace +COPY_SCHEDULE 30 1 * * * From 8d34ba283adff305985e1f9f4ddf313f0da630f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Mon, 18 May 2026 16:53:11 +0100 Subject: [PATCH 02/15] fix: add % prefix to parameterized nodes and fix UInt64 types in org page pipes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../tinybird/datasources/org_page_kpis_copy_ds.datasource | 8 ++++---- .../datasources/org_page_projects_copy_ds.datasource | 2 +- services/libs/tinybird/pipes/org_page_kpis.pipe | 1 + services/libs/tinybird/pipes/org_page_profile.pipe | 2 ++ services/libs/tinybird/pipes/org_page_projects.pipe | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource index caf8a91668..177731c6dc 100644 --- a/services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource +++ b/services/libs/tinybird/datasources/org_page_kpis_copy_ds.datasource @@ -4,10 +4,10 @@ DESCRIPTION > SCHEMA > `organizationId` String, - `activeContributors` UInt32, - `activeContributorsPrevious` UInt32, - `maintainerRoles` UInt32, - `criticalProjects` UInt32, + `activeContributors` UInt64, + `activeContributorsPrevious` UInt64, + `maintainerRoles` UInt64, + `criticalProjects` UInt64, `computedAt` DateTime ENGINE ReplacingMergeTree diff --git a/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource index a0bc378bc1..e2ce2bddc4 100644 --- a/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource +++ b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource @@ -9,7 +9,7 @@ SCHEMA > `projectName` String, `projectLogo` String, `activityCount` UInt64, - `contributorCount` UInt32, + `contributorCount` UInt64, `computedAt` DateTime ENGINE ReplacingMergeTree diff --git a/services/libs/tinybird/pipes/org_page_kpis.pipe b/services/libs/tinybird/pipes/org_page_kpis.pipe index e7cc43f13d..8c8534ff4c 100644 --- a/services/libs/tinybird/pipes/org_page_kpis.pipe +++ b/services/libs/tinybird/pipes/org_page_kpis.pipe @@ -6,6 +6,7 @@ TAGS "Organization page" NODE org_page_kpis_main SQL > + % SELECT activeContributors, if( diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe index d65ec0eb72..63e0d34f7c 100644 --- a/services/libs/tinybird/pipes/org_page_profile.pipe +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -6,6 +6,7 @@ TAGS "Organization page" NODE org_page_profile_base SQL > + % SELECT id, displayName, @@ -18,6 +19,7 @@ SQL > NODE org_page_profile_website SQL > + % SELECT organizationId, argMax(value, updatedAt) AS website diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index 4ca92f95c5..3bf1a1eabf 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -6,6 +6,7 @@ TAGS "Organization page" NODE org_page_projects_main SQL > + % SELECT projectSlug, projectName, From 78eea71f7555c345214e50ea074e64468feeda41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Mon, 18 May 2026 17:00:45 +0100 Subject: [PATCH 03/15] feat: simplify timeseries pipes to yearly all-time granularity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../pipes/org_page_activities_timeseries.pipe | 109 +---------------- .../org_page_contributors_timeseries.pipe | 111 +----------------- 2 files changed, 11 insertions(+), 209 deletions(-) diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe index 0929bf0975..129ff51389 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -1,115 +1,16 @@ DESCRIPTION > - Activity timeseries for a given organization, bucketed by granularity. - Filters to activities where the member belongs to the given org. + Activity timeseries for a given organization, bucketed by year (all-time). TAGS "Organization page" -NODE org_page_activities_bounds -SQL > - % - SELECT min(timestamp) AS actual_start_date, max(timestamp) AS actual_end_date - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - {% if defined(startDate) %} - AND timestamp >= {{ DateTime(startDate, description="Filter activity timestamp after") }} - {% end %} - {% if defined(endDate) %} - AND timestamp < {{ DateTime(endDate, description="Filter activity timestamp before") }} - {% end %} - NODE org_page_activities_timeseries_data SQL > % SELECT - CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(addDays(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) - END AS startDate, - CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(addDays(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN - toDate( - toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) - + INTERVAL 6 DAY - ) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN - toDate( - toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) - + INTERVAL 1 MONTH - - INTERVAL 1 DAY - ) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN - toDate( - toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) - + INTERVAL 3 MONTH - - INTERVAL 1 DAY - ) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN - toDate( - toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) - + INTERVAL 1 YEAR - - INTERVAL 1 DAY - ) - END AS endDate, + toStartOfYear(timestamp) AS startDate, + toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate, count() AS activityCount - FROM numbers(1000) numbers - CROSS JOIN - ( - SELECT - CASE - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(actual_start_date) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(actual_start_date) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(actual_start_date) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(actual_start_date) - ELSE actual_start_date - END AS actual_start_date, - actual_end_date - FROM org_page_activities_bounds - ) bounds - LEFT JOIN - activityRelations_deduplicated_cleaned_bucket_union af - ON organizationId = {{ String(orgId, '') }} - AND CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(af.timestamp) - END = CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(addDays(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) - END - WHERE startDate >= bounds.actual_start_date AND startDate < bounds.actual_end_date + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} GROUP BY startDate, endDate ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe index 821450be94..fbf5837a70 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -1,115 +1,16 @@ DESCRIPTION > - Contributor count timeseries for a given organization, bucketed by granularity. - Filters to activities where the member belongs to the given org. + Contributor count timeseries for a given organization, bucketed by year (all-time). TAGS "Organization page" -NODE org_page_contributors_bounds -SQL > - % - SELECT min(timestamp) AS actual_start_date, max(timestamp) AS actual_end_date - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - {% if defined(startDate) %} - AND timestamp >= {{ DateTime(startDate, description="Filter activity timestamp after") }} - {% end %} - {% if defined(endDate) %} - AND timestamp < {{ DateTime(endDate, description="Filter activity timestamp before") }} - {% end %} - NODE org_page_contributors_timeseries_data SQL > % SELECT - CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(addDays(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) - END AS startDate, - CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(addDays(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN - toDate( - toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) - + INTERVAL 6 DAY - ) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN - toDate( - toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) - + INTERVAL 1 MONTH - - INTERVAL 1 DAY - ) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN - toDate( - toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) - + INTERVAL 3 MONTH - - INTERVAL 1 DAY - ) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN - toDate( - toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) - + INTERVAL 1 YEAR - - INTERVAL 1 DAY - ) - END AS endDate, - uniqExact(af.memberId) AS contributorCount - FROM numbers(1000) numbers - CROSS JOIN - ( - SELECT - CASE - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(actual_start_date) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(actual_start_date) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(actual_start_date) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(actual_start_date) - ELSE actual_start_date - END AS actual_start_date, - actual_end_date - FROM org_page_contributors_bounds - ) bounds - LEFT JOIN - activityRelations_deduplicated_cleaned_bucket_union af - ON organizationId = {{ String(orgId, '') }} - AND CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(af.timestamp) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(af.timestamp) - END = CASE - WHEN {{ String(granularity, 'monthly') }} = 'daily' - THEN toDate(addDays(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'weekly' - THEN toStartOfWeek(addDays(bounds.actual_start_date, numbers.number * 7)) - WHEN {{ String(granularity, 'monthly') }} = 'monthly' - THEN toStartOfMonth(addMonths(bounds.actual_start_date, numbers.number)) - WHEN {{ String(granularity, 'monthly') }} = 'quarterly' - THEN toStartOfQuarter(addMonths(bounds.actual_start_date, numbers.number * 3)) - WHEN {{ String(granularity, 'monthly') }} = 'yearly' - THEN toStartOfYear(addYears(bounds.actual_start_date, numbers.number)) - END - WHERE startDate >= bounds.actual_start_date AND startDate < bounds.actual_end_date + toStartOfYear(timestamp) AS startDate, + toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate, + uniqExact(memberId) AS contributorCount + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} GROUP BY startDate, endDate ORDER BY startDate From 908b5471ca7ae705f8f9dceac6a779b9a7c37717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Mon, 18 May 2026 18:05:34 +0100 Subject: [PATCH 04/15] feat: filter org timeseries from 2005 and limit projects to 20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- services/libs/tinybird/pipes/org_page_activities_timeseries.pipe | 1 + .../libs/tinybird/pipes/org_page_contributors_timeseries.pipe | 1 + services/libs/tinybird/pipes/org_page_projects.pipe | 1 + 3 files changed, 3 insertions(+) diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe index 129ff51389..09129fccb9 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -12,5 +12,6 @@ SQL > count() AS activityCount FROM activityRelations_deduplicated_cleaned_bucket_union WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + AND timestamp >= '2005-01-01' GROUP BY startDate, endDate ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe index fbf5837a70..580d7e66b3 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -12,5 +12,6 @@ SQL > uniqExact(memberId) AS contributorCount FROM activityRelations_deduplicated_cleaned_bucket_union WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + AND timestamp >= '2005-01-01' GROUP BY startDate, endDate ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index 3bf1a1eabf..275d9a579b 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -16,3 +16,4 @@ SQL > FROM org_page_projects_copy_ds FINAL WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} ORDER BY activityCount DESC + LIMIT 20 From 283716f8f9b4a0a82021f92d8ebf6de888f5a466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Mon, 18 May 2026 18:15:35 +0100 Subject: [PATCH 05/15] chore: apply tb fmt to org page pipes and datasources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../pipes/org_page_activities_timeseries.pipe | 5 +++-- .../pipes/org_page_contributors_timeseries.pipe | 5 +++-- services/libs/tinybird/pipes/org_page_kpis.pipe | 9 ++++++--- services/libs/tinybird/pipes/org_page_profile.pipe | 12 ++---------- services/libs/tinybird/pipes/org_page_projects.pipe | 7 +------ 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe index 09129fccb9..993263b7ee 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -11,7 +11,8 @@ SQL > toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate, count() AS activityCount FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - AND timestamp >= '2005-01-01' + WHERE + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + AND timestamp >= '2005-01-01' GROUP BY startDate, endDate ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe index 580d7e66b3..cbde3adea3 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -11,7 +11,8 @@ SQL > toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate, uniqExact(memberId) AS contributorCount FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - AND timestamp >= '2005-01-01' + WHERE + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + AND timestamp >= '2005-01-01' GROUP BY startDate, endDate ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_kpis.pipe b/services/libs/tinybird/pipes/org_page_kpis.pipe index 8c8534ff4c..183dc71a80 100644 --- a/services/libs/tinybird/pipes/org_page_kpis.pipe +++ b/services/libs/tinybird/pipes/org_page_kpis.pipe @@ -10,14 +10,17 @@ SQL > SELECT activeContributors, if( - activeContributorsPrevious = 0, 0, + activeContributorsPrevious = 0, + 0, round( (toInt64(activeContributors) - toInt64(activeContributorsPrevious)) - / activeContributorsPrevious * 100, + / activeContributorsPrevious + * 100, 1 ) ) AS activeContributorsTrend, - toInt64(activeContributors) - toInt64(activeContributorsPrevious) AS activeContributorsTrendAbsolute, + toInt64(activeContributors) + - toInt64(activeContributorsPrevious) AS activeContributorsTrendAbsolute, activeContributorsPrevious AS activeContributorsTrendPrevious, maintainerRoles, criticalProjects diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe index 63e0d34f7c..aa7df605c0 100644 --- a/services/libs/tinybird/pipes/org_page_profile.pipe +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -7,22 +7,14 @@ TAGS "Organization page" NODE org_page_profile_base SQL > % - SELECT - id, - displayName, - logo, - employees AS employeeCount, - industry, - headline AS description + SELECT id, displayName, logo, employees AS employeeCount, industry, headline AS description FROM organizations FINAL WHERE id = {{ String(orgId, '', description="Organization ID", required=True) }} NODE org_page_profile_website SQL > % - SELECT - organizationId, - argMax(value, updatedAt) AS website + SELECT organizationId, argMax(value, updatedAt) AS website FROM organizationIdentities FINAL WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index 275d9a579b..7daf84e5db 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -7,12 +7,7 @@ TAGS "Organization page" NODE org_page_projects_main SQL > % - SELECT - projectSlug, - projectName, - projectLogo, - activityCount, - contributorCount + SELECT projectSlug, projectName, projectLogo, activityCount, contributorCount FROM org_page_projects_copy_ds FINAL WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} ORDER BY activityCount DESC From 85aed8139fdc6543e6514bb9d734aa5cdd010c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Tue, 19 May 2026 16:59:53 +0100 Subject: [PATCH 06/15] feat: add technical score to org page projects copy pipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../org_page_projects_copy_ds.datasource | 8 +++ .../tinybird/pipes/org_page_projects.pipe | 20 +++++-- .../pipes/org_page_projects_copy_pipe.pipe | 53 +++++++++++++++++++ 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource index e2ce2bddc4..ab521a6689 100644 --- a/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource +++ b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource @@ -10,6 +10,14 @@ SCHEMA > `projectLogo` String, `activityCount` UInt64, `contributorCount` UInt64, + `maintainersCount` UInt64, + `totalContributors` UInt64, + `orgContributors` UInt64, + `totalCommits` UInt64, + `orgCommits` UInt64, + `totalPrsOpened` UInt64, + `orgPrsOpened` UInt64, + `technicalScore` UInt64, `computedAt` DateTime ENGINE ReplacingMergeTree diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index 7daf84e5db..661435a8a9 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -7,8 +7,22 @@ TAGS "Organization page" NODE org_page_projects_main SQL > % - SELECT projectSlug, projectName, projectLogo, activityCount, contributorCount + SELECT + projectSlug, + projectName, + projectLogo, + activityCount, + contributorCount, + maintainersCount, + totalContributors, + orgContributors, + totalCommits, + orgCommits, + totalPrsOpened, + orgPrsOpened, + technicalScore FROM org_page_projects_copy_ds FINAL WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - ORDER BY activityCount DESC - LIMIT 20 + ORDER BY technicalScore DESC, activityCount DESC + LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }} + OFFSET {{ Int32(offset, 0, description="Pagination offset") }} diff --git a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe index c038f348c2..f076028028 100644 --- a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe @@ -35,6 +35,59 @@ SQL > LEFT JOIN insights_projects_populated_ds p ON a.segmentId = p.segmentId WHERE p.slug != '' +NODE org_page_projects_with_scores +DESCRIPTION > + Join with org_dash_metric_copy_ds to compute technical influence score + +SQL > + SELECT + w.organizationId, + w.segmentId, + w.projectSlug, + w.projectName, + w.projectLogo, + w.activityCount, + w.contributorCount, + ifNull(m.maintainersCount, 0) AS maintainersCount, + ifNull(m.contributorCount, 0) AS totalContributors, + ifNull(m.orgContributorCount, 0) AS orgContributors, + ifNull(m.commits, 0) AS totalCommits, + ifNull(m.orgCommits, 0) AS orgCommits, + ifNull(m.prsOpened, 0) AS totalPrsOpened, + ifNull(m.orgPrsOpened, 0) AS orgPrsOpened, + ( + -- Maintainers: 3 pts if org has at least 1 maintainer + CASE WHEN ifNull(m.maintainersCount, 0) >= 1 THEN 3 ELSE 0 END + -- Contributors: % of org contributors vs total + + CASE + WHEN ifNull(m.contributorCount, 0) = 0 THEN 0 + WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 20 THEN 3 + WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 5 THEN 2 + WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 1 THEN 1 + ELSE 0 + END + -- Commits: % of org commits vs total + + CASE + WHEN ifNull(m.commits, 0) = 0 THEN 0 + WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 20 THEN 3 + WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 5 THEN 2 + WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 1 THEN 1 + ELSE 0 + END + -- PRs opened: % of org PRs vs total + + CASE + WHEN ifNull(m.prsOpened, 0) = 0 THEN 0 + WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 20 THEN 3 + WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 5 THEN 2 + WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 1 THEN 1 + ELSE 0 + END + ) AS technicalScore, + w.computedAt + FROM org_page_projects_with_meta w + LEFT JOIN org_dash_metric_copy_ds m + ON w.organizationId = m.organizationId AND w.projectSlug = m.slug + TYPE COPY TARGET_DATASOURCE org_page_projects_copy_ds COPY_MODE replace From 84531dba1b19a19e57c8faebdeaf2c1d544abbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Tue, 19 May 2026 17:01:45 +0100 Subject: [PATCH 07/15] feat: add copy pipes and datasources for org page timeseries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- ...e_activities_timeseries_copy_ds.datasource | 14 ++++++++++++ ...contributors_timeseries_copy_ds.datasource | 14 ++++++++++++ .../pipes/org_page_activities_timeseries.pipe | 12 +++------- ..._page_activities_timeseries_copy_pipe.pipe | 22 +++++++++++++++++++ .../tinybird/pipes/org_page_contributors.pipe | 2 +- .../org_page_contributors_timeseries.pipe | 12 +++------- ...age_contributors_timeseries_copy_pipe.pipe | 22 +++++++++++++++++++ .../pipes/org_page_kpis_copy_pipe.pipe | 8 +++++-- .../libs/tinybird/pipes/org_page_profile.pipe | 3 +-- 9 files changed, 86 insertions(+), 23 deletions(-) create mode 100644 services/libs/tinybird/datasources/org_page_activities_timeseries_copy_ds.datasource create mode 100644 services/libs/tinybird/datasources/org_page_contributors_timeseries_copy_ds.datasource create mode 100644 services/libs/tinybird/pipes/org_page_activities_timeseries_copy_pipe.pipe create mode 100644 services/libs/tinybird/pipes/org_page_contributors_timeseries_copy_pipe.pipe diff --git a/services/libs/tinybird/datasources/org_page_activities_timeseries_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_activities_timeseries_copy_ds.datasource new file mode 100644 index 0000000000..592a7af102 --- /dev/null +++ b/services/libs/tinybird/datasources/org_page_activities_timeseries_copy_ds.datasource @@ -0,0 +1,14 @@ +DESCRIPTION > + Precomputed yearly activity counts per organization for the org page. Rebuilt nightly by org_page_activities_timeseries_copy_pipe. + One row per (organizationId, startDate). Used by org_page_activities_timeseries.pipe for cheap request-time lookups. + +SCHEMA > + `organizationId` String, + `startDate` Date, + `endDate` Date, + `activityCount` UInt64, + `computedAt` DateTime + +ENGINE ReplacingMergeTree +ENGINE_SORTING_KEY organizationId, startDate +ENGINE_VER computedAt diff --git a/services/libs/tinybird/datasources/org_page_contributors_timeseries_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_contributors_timeseries_copy_ds.datasource new file mode 100644 index 0000000000..61641f00b5 --- /dev/null +++ b/services/libs/tinybird/datasources/org_page_contributors_timeseries_copy_ds.datasource @@ -0,0 +1,14 @@ +DESCRIPTION > + Precomputed yearly unique contributor counts per organization for the org page. Rebuilt nightly by org_page_contributors_timeseries_copy_pipe. + One row per (organizationId, startDate). Used by org_page_contributors_timeseries.pipe for cheap request-time lookups. + +SCHEMA > + `organizationId` String, + `startDate` Date, + `endDate` Date, + `contributorCount` UInt64, + `computedAt` DateTime + +ENGINE ReplacingMergeTree +ENGINE_SORTING_KEY organizationId, startDate +ENGINE_VER computedAt diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe index 993263b7ee..3f7d4c2f29 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -6,13 +6,7 @@ TAGS "Organization page" NODE org_page_activities_timeseries_data SQL > % - SELECT - toStartOfYear(timestamp) AS startDate, - toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate, - count() AS activityCount - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - AND timestamp >= '2005-01-01' - GROUP BY startDate, endDate + SELECT startDate, endDate, activityCount + FROM org_page_activities_timeseries_copy_ds FINAL + WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} ORDER BY startDate 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 new file mode 100644 index 0000000000..66488d051e --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries_copy_pipe.pipe @@ -0,0 +1,22 @@ +DESCRIPTION > + Nightly copy pipe that precomputes yearly activity counts per organization for the org page. + Writes one row per (organizationId, startDate) into org_page_activities_timeseries_copy_ds. + +TAGS "Organization page" + +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, + count() AS activityCount, + now() AS computedAt + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE organizationId != '' AND timestamp >= '2005-01-01' + GROUP BY organizationId, startDate, endDate + +TYPE COPY +TARGET_DATASOURCE org_page_activities_timeseries_copy_ds +COPY_MODE replace +COPY_SCHEDULE 30 1 * * * diff --git a/services/libs/tinybird/pipes/org_page_contributors.pipe b/services/libs/tinybird/pipes/org_page_contributors.pipe index c5cd90d428..da3d54d7ac 100644 --- a/services/libs/tinybird/pipes/org_page_contributors.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors.pipe @@ -47,7 +47,7 @@ SQL > SELECT count(distinct memberId) as count FROM activityRelations_deduplicated_cleaned_bucket_union WHERE - organizationId = {{ String(orgId, '') }} + organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} {% if defined(startDate) %} AND timestamp >= {{ DateTime(startDate) }} {% end %} {% if defined(endDate) %} AND timestamp < {{ DateTime(endDate) }} {% end %} {% else %} diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe index cbde3adea3..15f7ee548d 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -6,13 +6,7 @@ TAGS "Organization page" NODE org_page_contributors_timeseries_data SQL > % - SELECT - toStartOfYear(timestamp) AS startDate, - toDate(toStartOfYear(timestamp) + INTERVAL 1 YEAR - INTERVAL 1 DAY) AS endDate, - uniqExact(memberId) AS contributorCount - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - AND timestamp >= '2005-01-01' - GROUP BY startDate, endDate + SELECT startDate, endDate, contributorCount + FROM org_page_contributors_timeseries_copy_ds FINAL + WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} ORDER BY startDate 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 new file mode 100644 index 0000000000..17d07df8f2 --- /dev/null +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries_copy_pipe.pipe @@ -0,0 +1,22 @@ +DESCRIPTION > + Nightly copy pipe that precomputes yearly unique contributor counts per organization for the org page. + Writes one row per (organizationId, startDate) into org_page_contributors_timeseries_copy_ds. + +TAGS "Organization page" + +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, + now() AS computedAt + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE organizationId != '' AND timestamp >= '2005-01-01' + GROUP BY organizationId, startDate, endDate + +TYPE COPY +TARGET_DATASOURCE org_page_contributors_timeseries_copy_ds +COPY_MODE replace +COPY_SCHEDULE 45 1 * * * 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 ee360f7f35..2424dcf6a2 100644 --- a/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_kpis_copy_pipe.pipe @@ -70,8 +70,12 @@ SQL > now() AS computedAt FROM org_page_kpis_current_contributors c FULL OUTER JOIN org_page_kpis_previous_contributors p ON c.organizationId = p.organizationId - FULL OUTER JOIN org_page_kpis_maintainer_roles m ON c.organizationId = m.organizationId - FULL OUTER JOIN org_page_kpis_critical_projects cp ON c.organizationId = cp.organizationId + FULL OUTER JOIN + org_page_kpis_maintainer_roles m + ON coalesce(c.organizationId, p.organizationId) = m.organizationId + FULL OUTER JOIN + org_page_kpis_critical_projects cp + ON coalesce(c.organizationId, p.organizationId, m.organizationId) = cp.organizationId WHERE organizationId != '' TYPE COPY diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe index aa7df605c0..cc9b2a8179 100644 --- a/services/libs/tinybird/pipes/org_page_profile.pipe +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -18,8 +18,7 @@ SQL > FROM organizationIdentities FINAL WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} - AND platform = 'website' - AND type = 'primary' + AND type = 'primary-domain' GROUP BY organizationId NODE org_page_profile_final From fc1a7d1029e7cfb3bda38f2ea198b19a4a29931f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Tue, 19 May 2026 17:03:39 +0100 Subject: [PATCH 08/15] chore: apply tb fmt to org page projects copy pipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../pipes/org_page_projects_copy_pipe.pipe | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe index f076028028..776b563e26 100644 --- a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe @@ -57,36 +57,47 @@ SQL > ifNull(m.orgPrsOpened, 0) AS orgPrsOpened, ( -- Maintainers: 3 pts if org has at least 1 maintainer - CASE WHEN ifNull(m.maintainersCount, 0) >= 1 THEN 3 ELSE 0 END -- Contributors: % of org contributors vs total - + CASE - WHEN ifNull(m.contributorCount, 0) = 0 THEN 0 - WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 20 THEN 3 - WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 5 THEN 2 - WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 1 THEN 1 + CASE WHEN ifNull(m.maintainersCount, 0) >= 1 THEN 3 ELSE 0 END + CASE + WHEN ifNull(m.contributorCount, 0) = 0 + THEN 0 + WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 20 + THEN 3 + WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 5 + THEN 2 + WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 1 + THEN 1 ELSE 0 - END + END -- Commits: % of org commits vs total + CASE - WHEN ifNull(m.commits, 0) = 0 THEN 0 - WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 20 THEN 3 - WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 5 THEN 2 - WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 1 THEN 1 + WHEN ifNull(m.commits, 0) = 0 + THEN 0 + WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 20 + THEN 3 + WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 5 + THEN 2 + WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 1 + THEN 1 ELSE 0 - END + END -- PRs opened: % of org PRs vs total + CASE - WHEN ifNull(m.prsOpened, 0) = 0 THEN 0 - WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 20 THEN 3 - WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 5 THEN 2 - WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 1 THEN 1 + WHEN ifNull(m.prsOpened, 0) = 0 + THEN 0 + WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 20 + THEN 3 + WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 5 + THEN 2 + WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 1 + THEN 1 ELSE 0 - END + END ) AS technicalScore, w.computedAt FROM org_page_projects_with_meta w - LEFT JOIN org_dash_metric_copy_ds m - ON w.organizationId = m.organizationId AND w.projectSlug = m.slug + LEFT JOIN + org_dash_metric_copy_ds m ON w.organizationId = m.organizationId AND w.projectSlug = m.slug TYPE COPY TARGET_DATASOURCE org_page_projects_copy_ds From 546d061a37bfb31451b6c4851ef0ebba5346a327 Mon Sep 17 00:00:00 2001 From: Joana Maia Date: Wed, 20 May 2026 13:51:36 +0100 Subject: [PATCH 09/15] fix: technical influence score Signed-off-by: Joana Maia --- .../org_page_projects_copy_ds.datasource | 2 +- .../pipes/org_page_projects_copy_pipe.pipe | 151 +++++++++++++----- 2 files changed, 110 insertions(+), 43 deletions(-) diff --git a/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource index ab521a6689..8ac6529e0a 100644 --- a/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource +++ b/services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource @@ -17,7 +17,7 @@ SCHEMA > `orgCommits` UInt64, `totalPrsOpened` UInt64, `orgPrsOpened` UInt64, - `technicalScore` UInt64, + `technicalScore` Float64, `computedAt` DateTime ENGINE ReplacingMergeTree diff --git a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe index 776b563e26..3d337144bc 100644 --- a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe @@ -19,12 +19,13 @@ SQL > NODE org_page_projects_with_meta DESCRIPTION > - Enrich with project name, logo and slug from insights_projects_populated_ds + Enrich with project name, logo, slug, and id from insights_projects_populated_ds SQL > SELECT a.organizationId, a.segmentId, + p.id AS projectId, p.slug AS projectSlug, p.name AS projectName, p.logoUrl AS projectLogo, @@ -35,19 +36,86 @@ SQL > LEFT JOIN insights_projects_populated_ds p ON a.segmentId = p.segmentId WHERE p.slug != '' +NODE org_page_projects_score_project_code_activity +DESCRIPTION > + Project-level code-only activity totals over the last 24 months, used only for the technical score + +SQL > + SELECT + segmentId, + countIf( + case when activityId != '' then activityId else null end, type = 'authored-commit' + ) AS scoreCommits, + countIf( + case when activityId != '' then activityId else null end, + type IN ('pull_request-opened', 'merge_request-opened', 'changeset-created') + ) AS scorePrsOpened, + uniqIf( + memberId, + type + IN ('authored-commit', 'pull_request-opened', 'merge_request-opened', 'changeset-created') + ) AS scoreContributorCount + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + timestamp >= toStartOfDay(now() - toIntervalDay(730)) + AND timestamp < toStartOfDay(now() + toIntervalDay(1)) + GROUP BY segmentId + +NODE org_page_projects_score_org_code_activity +DESCRIPTION > + Org-level code-only activity totals over the last 24 months, used only for the technical score + +SQL > + SELECT + segmentId, + organizationId, + countIf( + case when activityId != '' then activityId else null end, type = 'authored-commit' + ) AS scoreOrgCommits, + countIf( + case when activityId != '' then activityId else null end, + type IN ('pull_request-opened', 'merge_request-opened', 'changeset-created') + ) AS scoreOrgPrsOpened, + uniqIf( + memberId, + type + IN ('authored-commit', 'pull_request-opened', 'merge_request-opened', 'changeset-created') + ) AS scoreOrgContributorCount + FROM activityRelations_deduplicated_cleaned_bucket_union + WHERE + organizationId != '' + AND timestamp >= toStartOfDay(now() - toIntervalDay(730)) + AND timestamp < toStartOfDay(now() + toIntervalDay(1)) + GROUP BY segmentId, organizationId + +NODE org_page_projects_score_active_maintainers +DESCRIPTION > + Active maintainers per (insightsProjectId, organizationId): active means started and not ended more than 24 months ago + +SQL > + SELECT insightsProjectId, organizationId, uniq(memberId) AS scoreMaintainersCount + FROM maintainers_roles_copy_ds + WHERE + role = 'maintainer' + AND organizationId != '' + AND startDate <= now() + AND (toYear(endDate) <= 1970 OR endDate >= now() - toIntervalDay(730)) + GROUP BY insightsProjectId, organizationId + NODE org_page_projects_with_scores DESCRIPTION > - Join with org_dash_metric_copy_ds to compute technical influence score + Compute technical influence score from spec-compliant 24-month code-only inputs. + Display columns (maintainersCount, totalContributors, etc.) remain sourced from org_dash_metric_copy_ds. SQL > SELECT - w.organizationId, - w.segmentId, - w.projectSlug, - w.projectName, - w.projectLogo, - w.activityCount, - w.contributorCount, + w.organizationId AS organizationId, + w.segmentId AS segmentId, + w.projectSlug AS projectSlug, + w.projectName AS projectName, + w.projectLogo AS projectLogo, + w.activityCount AS activityCount, + w.contributorCount AS contributorCount, ifNull(m.maintainersCount, 0) AS maintainersCount, ifNull(m.contributorCount, 0) AS totalContributors, ifNull(m.orgContributorCount, 0) AS orgContributors, @@ -56,48 +124,47 @@ SQL > ifNull(m.prsOpened, 0) AS totalPrsOpened, ifNull(m.orgPrsOpened, 0) AS orgPrsOpened, ( - -- Maintainers: 3 pts if org has at least 1 maintainer - -- Contributors: % of org contributors vs total - CASE WHEN ifNull(m.maintainersCount, 0) >= 1 THEN 3 ELSE 0 END + CASE - WHEN ifNull(m.contributorCount, 0) = 0 - THEN 0 - WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 20 - THEN 3 - WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 5 - THEN 2 - WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 1 - THEN 1 - ELSE 0 + -- Maintainers: 3 pts if org has at least 1 active maintainer (24-month window) + -- Contributors: 0 if no share; 1.1 if share in (0, 0.1%]; share + 1.0 otherwise + CASE WHEN ifNull(mt.scoreMaintainersCount, 0) >= 1 THEN 3.0 ELSE 0.0 END + CASE + WHEN + ifNull(pa.scoreContributorCount, 0) = 0 + OR ifNull(oa.scoreOrgContributorCount, 0) = 0 + THEN 0.0 + WHEN oa.scoreOrgContributorCount * 100.0 / pa.scoreContributorCount <= 0.1 + THEN 1.1 + ELSE round(oa.scoreOrgContributorCount * 100.0 / pa.scoreContributorCount + 1.0, 1) END - -- Commits: % of org commits vs total + -- Commits: same formula + CASE - WHEN ifNull(m.commits, 0) = 0 - THEN 0 - WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 20 - THEN 3 - WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 5 - THEN 2 - WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 1 - THEN 1 - ELSE 0 + WHEN ifNull(pa.scoreCommits, 0) = 0 OR ifNull(oa.scoreOrgCommits, 0) = 0 + THEN 0.0 + WHEN oa.scoreOrgCommits * 100.0 / pa.scoreCommits <= 0.1 + THEN 1.1 + ELSE round(oa.scoreOrgCommits * 100.0 / pa.scoreCommits + 1.0, 1) END - -- PRs opened: % of org PRs vs total + -- PRs opened: same formula + CASE - WHEN ifNull(m.prsOpened, 0) = 0 - THEN 0 - WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 20 - THEN 3 - WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 5 - THEN 2 - WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 1 - THEN 1 - ELSE 0 + WHEN ifNull(pa.scorePrsOpened, 0) = 0 OR ifNull(oa.scoreOrgPrsOpened, 0) = 0 + THEN 0.0 + WHEN oa.scoreOrgPrsOpened * 100.0 / pa.scorePrsOpened <= 0.1 + THEN 1.1 + ELSE round(oa.scoreOrgPrsOpened * 100.0 / pa.scorePrsOpened + 1.0, 1) END ) AS technicalScore, - w.computedAt + w.computedAt AS computedAt FROM org_page_projects_with_meta w LEFT JOIN org_dash_metric_copy_ds m ON w.organizationId = m.organizationId AND w.projectSlug = m.slug + LEFT JOIN org_page_projects_score_project_code_activity pa ON w.segmentId = pa.segmentId + LEFT JOIN + org_page_projects_score_org_code_activity oa + ON w.segmentId = oa.segmentId + AND w.organizationId = oa.organizationId + LEFT JOIN + org_page_projects_score_active_maintainers mt + ON w.projectId = mt.insightsProjectId + AND w.organizationId = mt.organizationId TYPE COPY TARGET_DATASOURCE org_page_projects_copy_ds From b3872689767b9c228293c6f0825d34b300a64f3b Mon Sep 17 00:00:00 2001 From: Joana Maia Date: Wed, 20 May 2026 15:49:35 +0100 Subject: [PATCH 10/15] chore: update org page pipes to use slug instead of id Signed-off-by: Joana Maia --- .../pipes/org_page_activities_timeseries.pipe | 9 +++++++-- .../libs/tinybird/pipes/org_page_contributors.pipe | 12 +++++++++--- .../pipes/org_page_contributors_timeseries.pipe | 9 +++++++-- services/libs/tinybird/pipes/org_page_kpis.pipe | 9 +++++++-- services/libs/tinybird/pipes/org_page_profile.pipe | 12 ++++++++---- services/libs/tinybird/pipes/org_page_projects.pipe | 8 +++++++- .../tinybird/pipes/organizations_leaderboard.pipe | 7 ++++--- 7 files changed, 49 insertions(+), 17 deletions(-) diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe index 3f7d4c2f29..44b7f84d5c 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -3,10 +3,15 @@ DESCRIPTION > TAGS "Organization page" -NODE org_page_activities_timeseries_data +NODE org_slug_lookup SQL > % + SELECT id FROM organizations_populated_slug + WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} + +NODE org_page_activities_timeseries_data +SQL > SELECT startDate, endDate, activityCount FROM org_page_activities_timeseries_copy_ds FINAL - WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + WHERE organizationId = (SELECT id FROM org_slug_lookup) ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_contributors.pipe b/services/libs/tinybird/pipes/org_page_contributors.pipe index da3d54d7ac..3e0f3def61 100644 --- a/services/libs/tinybird/pipes/org_page_contributors.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors.pipe @@ -4,6 +4,12 @@ DESCRIPTION > TAGS "Organization page" +NODE org_slug_lookup +SQL > + % + SELECT id FROM organizations_populated_slug + WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} + NODE org_page_contributors_activity_aggregates SQL > % @@ -11,7 +17,7 @@ SQL > SELECT count(distinct memberId) FROM activityRelations_deduplicated_cleaned_bucket_union WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + organizationId = (SELECT id FROM org_slug_lookup) {% if defined(startDate) %} AND timestamp >= {{ DateTime(startDate, description="Filter activity timestamp after") }} @@ -26,7 +32,7 @@ SQL > ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (), 2) as "contributionPercentage" FROM activityRelations_deduplicated_cleaned_bucket_union WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + organizationId = (SELECT id FROM org_slug_lookup) {% if defined(startDate) %} AND timestamp >= {{ DateTime(startDate, description="Filter activity timestamp after") }} @@ -47,7 +53,7 @@ SQL > SELECT count(distinct memberId) as count FROM activityRelations_deduplicated_cleaned_bucket_union WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + organizationId = (SELECT id FROM org_slug_lookup) {% if defined(startDate) %} AND timestamp >= {{ DateTime(startDate) }} {% end %} {% if defined(endDate) %} AND timestamp < {{ DateTime(endDate) }} {% end %} {% else %} diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe index 15f7ee548d..5df0abf3fb 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -3,10 +3,15 @@ DESCRIPTION > TAGS "Organization page" -NODE org_page_contributors_timeseries_data +NODE org_slug_lookup SQL > % + SELECT id FROM organizations_populated_slug + WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} + +NODE org_page_contributors_timeseries_data +SQL > SELECT startDate, endDate, contributorCount FROM org_page_contributors_timeseries_copy_ds FINAL - WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + WHERE organizationId = (SELECT id FROM org_slug_lookup) ORDER BY startDate diff --git a/services/libs/tinybird/pipes/org_page_kpis.pipe b/services/libs/tinybird/pipes/org_page_kpis.pipe index 183dc71a80..c11d4ca4a5 100644 --- a/services/libs/tinybird/pipes/org_page_kpis.pipe +++ b/services/libs/tinybird/pipes/org_page_kpis.pipe @@ -4,9 +4,14 @@ DESCRIPTION > TAGS "Organization page" -NODE org_page_kpis_main +NODE org_slug_lookup SQL > % + SELECT id FROM organizations_populated_slug + WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} + +NODE org_page_kpis_main +SQL > SELECT activeContributors, if( @@ -25,4 +30,4 @@ SQL > maintainerRoles, criticalProjects FROM org_page_kpis_copy_ds FINAL - WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + WHERE organizationId = (SELECT id FROM org_slug_lookup) diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe index cc9b2a8179..0dcba98c84 100644 --- a/services/libs/tinybird/pipes/org_page_profile.pipe +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -4,20 +4,24 @@ DESCRIPTION > TAGS "Organization page" -NODE org_page_profile_base +NODE org_slug_lookup SQL > % + SELECT id FROM organizations_populated_slug + WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} + +NODE org_page_profile_base +SQL > SELECT id, displayName, logo, employees AS employeeCount, industry, headline AS description FROM organizations FINAL - WHERE id = {{ String(orgId, '', description="Organization ID", required=True) }} + WHERE id = (SELECT id FROM org_slug_lookup) NODE org_page_profile_website SQL > - % SELECT organizationId, argMax(value, updatedAt) AS website FROM organizationIdentities FINAL WHERE - organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + organizationId = (SELECT id FROM org_slug_lookup) AND type = 'primary-domain' GROUP BY organizationId diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index 661435a8a9..1c0a206047 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -4,6 +4,12 @@ DESCRIPTION > TAGS "Organization page" +NODE org_slug_lookup +SQL > + % + SELECT id FROM organizations_populated_slug + WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} + NODE org_page_projects_main SQL > % @@ -22,7 +28,7 @@ SQL > orgPrsOpened, technicalScore FROM org_page_projects_copy_ds FINAL - WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }} + WHERE organizationId = (SELECT id FROM org_slug_lookup) ORDER BY technicalScore DESC, activityCount DESC LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }} OFFSET {{ Int32(offset, 0, description="Pagination offset") }} diff --git a/services/libs/tinybird/pipes/organizations_leaderboard.pipe b/services/libs/tinybird/pipes/organizations_leaderboard.pipe index 23272d0977..c4ea670d92 100644 --- a/services/libs/tinybird/pipes/organizations_leaderboard.pipe +++ b/services/libs/tinybird/pipes/organizations_leaderboard.pipe @@ -18,7 +18,7 @@ DESCRIPTION > - `offset`: Optional integer for result pagination, defaults to 0 - Response: - Count mode (`count=true`): `count` (total number of organizations) - - Data mode (default): `id`, `logo`, `displayName`, `contributionCount`, `contributionPercentage` + - Data mode (default): `id`, `slug`, `logo`, `displayName`, `contributionCount`, `contributionPercentage` NODE organizations_leaderboard_paginated SQL > @@ -28,13 +28,14 @@ SQL > {% else %} SELECT org.id AS id, + org.slug AS slug, org.logo AS logo, org.displayName AS displayName, COUNT(af.id) AS contributionCount, ROUND(COUNT(af.id) * 100.0 / SUM(COUNT(af.id)) OVER (), 2) AS contributionPercentage FROM activities_filtered af - JOIN organizations org FINAL ON org.id = af.organizationId - GROUP BY org.id, org.logo, org.displayName + JOIN organizations_populated_slug org ON org.id = af.organizationId + GROUP BY org.id, org.slug, org.logo, org.displayName ORDER BY contributionCount DESC, id desc LIMIT {{ Int32(limit, 10) }} OFFSET {{ Int32(offset, 0) }} From 221825b10e80418b5592e529b5970288d845cec0 Mon Sep 17 00:00:00 2001 From: Joana Maia Date: Wed, 20 May 2026 16:10:19 +0100 Subject: [PATCH 11/15] fix: org_page pipes Signed-off-by: Joana Maia --- .../pipes/org_page_activities_timeseries_copy_pipe.pipe | 2 +- .../pipes/org_page_contributors_timeseries_copy_pipe.pipe | 2 +- services/libs/tinybird/pipes/org_page_profile.pipe | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 66488d051e..ec4fb4c61a 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 @@ -13,7 +13,7 @@ SQL > count() AS activityCount, now() AS computedAt FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE organizationId != '' AND timestamp >= '2005-01-01' + WHERE organizationId != '' AND timestamp >= '2016-01-01' GROUP BY organizationId, startDate, endDate TYPE COPY 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 17d07df8f2..2d594cc229 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 @@ -13,7 +13,7 @@ SQL > uniq(memberId) AS contributorCount, now() AS computedAt FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE organizationId != '' AND timestamp >= '2005-01-01' + WHERE organizationId != '' AND timestamp >= '2016-01-01' GROUP BY organizationId, startDate, endDate TYPE COPY diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe index 0dcba98c84..532156b7ea 100644 --- a/services/libs/tinybird/pipes/org_page_profile.pipe +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -12,7 +12,7 @@ SQL > NODE org_page_profile_base SQL > - SELECT id, displayName, logo, employees AS employeeCount, industry, headline AS description + SELECT id, displayName, logo, size AS employeeCount, industry, headline AS description FROM organizations FINAL WHERE id = (SELECT id FROM org_slug_lookup) From 2cd89cbb8e8c365463efbba411808bfdaf62cd7a Mon Sep 17 00:00:00 2001 From: Joana Maia Date: Wed, 20 May 2026 16:49:32 +0100 Subject: [PATCH 12/15] chore: add membership to org page Signed-off-by: Joana Maia --- .../libs/tinybird/pipes/org_page_profile.pipe | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe index 532156b7ea..aeefced339 100644 --- a/services/libs/tinybird/pipes/org_page_profile.pipe +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -25,6 +25,28 @@ SQL > AND type = 'primary-domain' GROUP BY organizationId +NODE org_page_profile_membership +SQL > + SELECT + organizationId, + replaceRegexpOne( + argMax( + if( + tier IN ('Silver Membership', 'Platinum Membership', 'Gold Membership', 'Associate Membership'), + tier, + extract(productName, ' - (.+) \\(') + ), + updatedAt + ), + ' Membership$', + '' + ) AS membership + FROM lfxMemberships FINAL + WHERE + organizationId = (SELECT id FROM org_slug_lookup) + AND project = 'The Linux Foundation' + GROUP BY organizationId + NODE org_page_profile_final SQL > SELECT @@ -35,6 +57,8 @@ SQL > b.industry, b.description, w.website, - domain(w.website) AS domain + domain(w.website) AS domain, + m.membership FROM org_page_profile_base b LEFT JOIN org_page_profile_website w ON b.id = w.organizationId + LEFT JOIN org_page_profile_membership m ON b.id = m.organizationId From a4d60cac9299813d9784847ed6955c5c4196537c Mon Sep 17 00:00:00 2001 From: Joana Maia Date: Wed, 20 May 2026 18:19:52 +0100 Subject: [PATCH 13/15] chore: add contributorCount to sorter Signed-off-by: Joana Maia --- services/libs/tinybird/pipes/org_page_projects.pipe | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index 1c0a206047..a538164ab5 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -29,6 +29,6 @@ SQL > technicalScore FROM org_page_projects_copy_ds FINAL WHERE organizationId = (SELECT id FROM org_slug_lookup) - ORDER BY technicalScore DESC, activityCount DESC + ORDER BY technicalScore DESC, contributorCount DESC, activityCount DESC LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }} OFFSET {{ Int32(offset, 0, description="Pagination offset") }} From 2754157e0652f1f16f49d7e3f70ccdb48771c079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Thu, 21 May 2026 02:06:12 +0100 Subject: [PATCH 14/15] feat: filter org projects by collaboration and code contribution activity types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../pipes/org_page_projects_copy_pipe.pipe | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe index 3d337144bc..f0d27d227b 100644 --- a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe @@ -4,18 +4,27 @@ DESCRIPTION > TAGS "Organization page" +NODE org_page_projects_contribution_activity_types +DESCRIPTION > + Collaboration and code contribution activity types (mirrors leaderboards filter) + +SQL > + SELECT activityType, platform FROM activityTypes FINAL WHERE isCollaboration OR isCodeContribution + NODE org_page_projects_org_segment_activity DESCRIPTION > - Activity and contributor counts per org per project segment in the last 365 days + Collaboration/code activity and contributor counts per org per project segment in the last 365 days SQL > - SELECT organizationId, segmentId, count() AS activityCount, uniq(memberId) AS contributorCount - FROM activityRelations_deduplicated_cleaned_bucket_union + SELECT ar.organizationId, ar.segmentId, count() AS activityCount, uniq(ar.memberId) AS contributorCount + FROM activityRelations_deduplicated_cleaned_bucket_union ar + INNER JOIN org_page_projects_contribution_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, segmentId + ar.organizationId != '' + AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(365)) + AND ar.timestamp < toStartOfDay(now() + toIntervalDay(1)) + GROUP BY ar.organizationId, ar.segmentId NODE org_page_projects_with_meta DESCRIPTION > From 6afbea752f558b6247b7038e91cddaaf9d155110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Thu, 21 May 2026 08:42:25 +0100 Subject: [PATCH 15/15] chore: format org page pipe SQL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../pipes/org_page_activities_timeseries.pipe | 3 ++- .../tinybird/pipes/org_page_contributors.pipe | 3 ++- .../org_page_contributors_timeseries.pipe | 3 ++- .../libs/tinybird/pipes/org_page_kpis.pipe | 3 ++- .../libs/tinybird/pipes/org_page_profile.pipe | 18 ++++++++++-------- .../libs/tinybird/pipes/org_page_projects.pipe | 3 ++- .../pipes/org_page_projects_copy_pipe.pipe | 9 ++++++--- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe index 44b7f84d5c..45e8644268 100644 --- a/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_activities_timeseries.pipe @@ -6,7 +6,8 @@ TAGS "Organization page" NODE org_slug_lookup SQL > % - SELECT id FROM organizations_populated_slug + SELECT id + FROM organizations_populated_slug WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} NODE org_page_activities_timeseries_data diff --git a/services/libs/tinybird/pipes/org_page_contributors.pipe b/services/libs/tinybird/pipes/org_page_contributors.pipe index 3e0f3def61..672816bbcc 100644 --- a/services/libs/tinybird/pipes/org_page_contributors.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors.pipe @@ -7,7 +7,8 @@ TAGS "Organization page" NODE org_slug_lookup SQL > % - SELECT id FROM organizations_populated_slug + SELECT id + FROM organizations_populated_slug WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} NODE org_page_contributors_activity_aggregates diff --git a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe index 5df0abf3fb..684edb208d 100644 --- a/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe +++ b/services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe @@ -6,7 +6,8 @@ TAGS "Organization page" NODE org_slug_lookup SQL > % - SELECT id FROM organizations_populated_slug + SELECT id + FROM organizations_populated_slug WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} NODE org_page_contributors_timeseries_data diff --git a/services/libs/tinybird/pipes/org_page_kpis.pipe b/services/libs/tinybird/pipes/org_page_kpis.pipe index c11d4ca4a5..b28bdb973b 100644 --- a/services/libs/tinybird/pipes/org_page_kpis.pipe +++ b/services/libs/tinybird/pipes/org_page_kpis.pipe @@ -7,7 +7,8 @@ TAGS "Organization page" NODE org_slug_lookup SQL > % - SELECT id FROM organizations_populated_slug + SELECT id + FROM organizations_populated_slug WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} NODE org_page_kpis_main diff --git a/services/libs/tinybird/pipes/org_page_profile.pipe b/services/libs/tinybird/pipes/org_page_profile.pipe index aeefced339..fc8d76665a 100644 --- a/services/libs/tinybird/pipes/org_page_profile.pipe +++ b/services/libs/tinybird/pipes/org_page_profile.pipe @@ -7,7 +7,8 @@ TAGS "Organization page" NODE org_slug_lookup SQL > % - SELECT id FROM organizations_populated_slug + SELECT id + FROM organizations_populated_slug WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} NODE org_page_profile_base @@ -20,9 +21,7 @@ NODE org_page_profile_website SQL > SELECT organizationId, argMax(value, updatedAt) AS website FROM organizationIdentities FINAL - WHERE - organizationId = (SELECT id FROM org_slug_lookup) - AND type = 'primary-domain' + WHERE organizationId = (SELECT id FROM org_slug_lookup) AND type = 'primary-domain' GROUP BY organizationId NODE org_page_profile_membership @@ -32,7 +31,12 @@ SQL > replaceRegexpOne( argMax( if( - tier IN ('Silver Membership', 'Platinum Membership', 'Gold Membership', 'Associate Membership'), + tier IN ( + 'Silver Membership', + 'Platinum Membership', + 'Gold Membership', + 'Associate Membership' + ), tier, extract(productName, ' - (.+) \\(') ), @@ -42,9 +46,7 @@ SQL > '' ) AS membership FROM lfxMemberships FINAL - WHERE - organizationId = (SELECT id FROM org_slug_lookup) - AND project = 'The Linux Foundation' + WHERE organizationId = (SELECT id FROM org_slug_lookup) AND project = 'The Linux Foundation' GROUP BY organizationId NODE org_page_profile_final diff --git a/services/libs/tinybird/pipes/org_page_projects.pipe b/services/libs/tinybird/pipes/org_page_projects.pipe index a538164ab5..61cfd2fa00 100644 --- a/services/libs/tinybird/pipes/org_page_projects.pipe +++ b/services/libs/tinybird/pipes/org_page_projects.pipe @@ -7,7 +7,8 @@ TAGS "Organization page" NODE org_slug_lookup SQL > % - SELECT id FROM organizations_populated_slug + SELECT id + FROM organizations_populated_slug WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }} NODE org_page_projects_main diff --git a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe index f0d27d227b..36035b0f61 100644 --- a/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe +++ b/services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe @@ -16,10 +16,13 @@ DESCRIPTION > Collaboration/code activity and contributor counts per org per project segment in the last 365 days SQL > - SELECT ar.organizationId, ar.segmentId, count() AS activityCount, uniq(ar.memberId) AS contributorCount + SELECT + ar.organizationId, ar.segmentId, count() AS activityCount, uniq(ar.memberId) AS contributorCount FROM activityRelations_deduplicated_cleaned_bucket_union ar - INNER JOIN org_page_projects_contribution_activity_types at - ON ar.type = at.activityType AND ar.platform = at.platform + INNER JOIN + org_page_projects_contribution_activity_types at + ON ar.type = at.activityType + AND ar.platform = at.platform WHERE ar.organizationId != '' AND ar.timestamp >= toStartOfDay(now() - toIntervalDay(365))