From 72205f60aa0787737694866d8fd641a7189820af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Mon, 12 Oct 2026 14:20:42 +0100 Subject: [PATCH] chore: remove the v1 repository health score pipes (IN-1222) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Delete repo_health_score_copy, repo_health_score_copy_ds and the ten repo_health_score_ pipes behind them. repo_health_score_contributor_dependency and repo_health_score_organization_dependency stay: project_insights_copy joins them for the repository dependency metrics. repo_health_score_v2_breakdown is the live v2 pipe and is untouched. Deleting the files does not remove the live resources: see the removal runbook in the PR. Signed-off-by: Gašper Grom --- .../repo_health_score_copy_ds.datasource | 71 --------- ...repo_health_score_active_contributors.pipe | 64 -------- .../pipes/repo_health_score_active_days.pipe | 60 -------- ...core_contributions_outside_work_hours.pipe | 71 --------- .../pipes/repo_health_score_copy.pipe | 140 ------------------ .../pipes/repo_health_score_forks.pipe | 58 -------- .../repo_health_score_issues_resolution.pipe | 62 -------- .../repo_health_score_merge_lead_time.pipe | 60 -------- .../repo_health_score_pull_requests.pipe | 70 --------- .../pipes/repo_health_score_retention.pipe | 133 ----------------- .../pipes/repo_health_score_security.pipe | 45 ------ .../pipes/repo_health_score_stars.pipe | 112 -------------- 12 files changed, 946 deletions(-) delete mode 100644 services/libs/tinybird/datasources/repo_health_score_copy_ds.datasource delete mode 100644 services/libs/tinybird/pipes/repo_health_score_active_contributors.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_active_days.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_contributions_outside_work_hours.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_copy.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_forks.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_issues_resolution.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_merge_lead_time.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_pull_requests.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_retention.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_security.pipe delete mode 100644 services/libs/tinybird/pipes/repo_health_score_stars.pipe diff --git a/services/libs/tinybird/datasources/repo_health_score_copy_ds.datasource b/services/libs/tinybird/datasources/repo_health_score_copy_ds.datasource deleted file mode 100644 index 168ed13032..0000000000 --- a/services/libs/tinybird/datasources/repo_health_score_copy_ds.datasource +++ /dev/null @@ -1,71 +0,0 @@ -DESCRIPTION > - - `repo_health_score_copy_ds` contains comprehensive health score metrics and benchmarks per repository. - - Created via copy pipe with computed health metrics for repository-level analytics. - - Aggregates multiple health dimensions including contributors, popularity, development activity, and security. - - `channel` is the repository URL used as the primary key. - - `activeContributors` is the unique contributor count for the previous quarter. - - `activeContributorsBenchmark` is the benchmark score (0-5) for active contributors. - - `contributorDependencyCount` measures contributor concentration risk (bus factor). - - `contributorDependencyPercentage` is the combined contribution percentage of dependent contributors. - - `contributorDependencyBenchmark` is the benchmark score (0-5) for contributor dependency. - - `organizationDependencyCount` measures organizational concentration risk. - - `organizationDependencyPercentage` is the combined contribution percentage of dependent organizations. - - `organizationDependencyBenchmark` is the benchmark score (0-5) for organization dependency. - - `retentionRate` is the quarter-over-quarter contributor retention percentage. - - `retentionBenchmark` is the benchmark score (0-5) for retention. - - `stars` is the total star count for the repository. - - `starsBenchmark` is the benchmark score (0-5) for stars. - - `forks` is the total fork count for the repository. - - `forksBenchmark` is the benchmark score (0-5) for forks. - - `issueResolution` is the average days to close issues (nullable for repos without issues). - - `issueResolutionBenchmark` is the benchmark score (0-5) for issue resolution. - - `pullRequests` is the PR count in the last 365 days. - - `pullRequestsBenchmark` is the benchmark score (0-5) for pull requests. - - `mergeLeadTime` is the average days to merge PRs (nullable for repos without PRs). - - `mergeLeadTimeBenchmark` is the benchmark score (0-5) for merge lead time. - - `activeDaysCount` is the count of distinct active days in the last 365 days. - - `activeDaysBenchmark` is the benchmark score (0-5) for active days. - - `contributionsOutsideWorkHours` is the percentage of contributions outside work hours. - - `contributionsOutsideWorkHoursBenchmark` is the benchmark score (0-5) for outside work hours. - - `securityPercentage` is the health score percentage for the security category (0-100). - - `contributorPercentage` is the health score percentage for the contributors category (0-100). - - `popularityPercentage` is the health score percentage for the popularity category (0-100). - - `developmentPercentage` is the health score percentage for the development category (0-100). - - `overallScore` is the computed overall health score combining all dimensions. - -TAGS "Repository health", "Metrics" - -SCHEMA > - `channel` String, - `activeContributors` UInt64, - `activeContributorsBenchmark` UInt64, - `contributorDependencyCount` UInt64, - `contributorDependencyPercentage` Float64, - `contributorDependencyBenchmark` UInt64, - `organizationDependencyCount` UInt64, - `organizationDependencyPercentage` Float64, - `organizationDependencyBenchmark` UInt64, - `retentionRate` Float64, - `retentionBenchmark` UInt64, - `stars` UInt64, - `starsBenchmark` UInt64, - `forks` UInt64, - `forksBenchmark` UInt64, - `issueResolution` Nullable(Float64), - `issueResolutionBenchmark` UInt64, - `pullRequests` UInt64, - `pullRequestsBenchmark` UInt64, - `mergeLeadTime` Nullable(Float64), - `mergeLeadTimeBenchmark` UInt64, - `activeDaysCount` UInt64, - `activeDaysBenchmark` UInt64, - `contributionsOutsideWorkHours` Float64, - `contributionsOutsideWorkHoursBenchmark` UInt64, - `securityPercentage` Float64, - `contributorPercentage` Float64, - `popularityPercentage` Float64, - `developmentPercentage` Float64, - `overallScore` Float64 - -ENGINE MergeTree -ENGINE_SORTING_KEY channel diff --git a/services/libs/tinybird/pipes/repo_health_score_active_contributors.pipe b/services/libs/tinybird/pipes/repo_health_score_active_contributors.pipe deleted file mode 100644 index 863f6fa051..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_active_contributors.pipe +++ /dev/null @@ -1,64 +0,0 @@ -DESCRIPTION > - - Calculates repository-level active contributors health score. - - Returns unique active contributor count and benchmark (0-5) per repository for the previous quarter. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Optional DateTime filter for contributions after timestamp - - `endDate`: Optional DateTime filter for contributions before timestamp - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_active_contributors_score -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, uniq(memberId) AS activeContributors - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - memberId != '' - AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered) - AND channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(startDate) %} - AND timestamp - > {{ DateTime(startDate, description="Filter after date", required=False) }} - {% end %} - {% if defined(endDate) %} - AND timestamp - < {{ DateTime(endDate, description="Filter before date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT channel, uniq(memberId) AS activeContributors - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - memberId != '' - AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered) - AND timestamp >= toStartOfQuarter(now() - toIntervalQuarter(1)) - AND timestamp < toStartOfQuarter(now()) - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - -NODE health_score_active_contributors_benchmark -SQL > - % - SELECT - channel, - activeContributors, - CASE - WHEN activeContributors BETWEEN 0 AND 1 - THEN 0 - WHEN activeContributors BETWEEN 2 AND 3 - THEN 1 - WHEN activeContributors BETWEEN 4 AND 6 - THEN 2 - WHEN activeContributors BETWEEN 7 AND 10 - THEN 3 - WHEN activeContributors BETWEEN 11 AND 20 - THEN 4 - WHEN activeContributors > 20 - THEN 5 - ELSE 0 - END AS activeContributorsBenchmark - FROM repo_health_score_active_contributors_score diff --git a/services/libs/tinybird/pipes/repo_health_score_active_days.pipe b/services/libs/tinybird/pipes/repo_health_score_active_days.pipe deleted file mode 100644 index 206dbab351..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_active_days.pipe +++ /dev/null @@ -1,60 +0,0 @@ -DESCRIPTION > - - Calculates repository-level active days health score. - - Returns count of distinct active days and benchmark (0-5) per repository for the last 365 days. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Optional DateTime filter - - `endDate`: Optional DateTime filter - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_active_days_score -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, countDistinct(DATE(timestamp)) AS activeDaysCount - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(startDate) %} - AND timestamp - > {{ DateTime(startDate, description="Filter after date", required=False) }} - {% end %} - {% if defined(endDate) %} - AND timestamp - < {{ DateTime(endDate, description="Filter before date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT channel, countDistinct(DATE(timestamp)) AS activeDaysCount - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - timestamp >= toStartOfDay(now() - toIntervalDay(365)) - AND timestamp < toStartOfDay(now()) - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - -NODE health_score_active_days_benchmark -SQL > - % - SELECT - channel, - activeDaysCount, - CASE - WHEN activeDaysCount BETWEEN 0 AND 5 - THEN 0 - WHEN activeDaysCount BETWEEN 6 AND 10 - THEN 1 - WHEN activeDaysCount BETWEEN 11 AND 15 - THEN 2 - WHEN activeDaysCount BETWEEN 16 AND 20 - THEN 3 - WHEN activeDaysCount BETWEEN 21 AND 26 - THEN 4 - WHEN activeDaysCount > 26 - THEN 5 - ELSE 0 - END AS activeDaysBenchmark - FROM repo_health_score_active_days_score diff --git a/services/libs/tinybird/pipes/repo_health_score_contributions_outside_work_hours.pipe b/services/libs/tinybird/pipes/repo_health_score_contributions_outside_work_hours.pipe deleted file mode 100644 index 043e066921..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_contributions_outside_work_hours.pipe +++ /dev/null @@ -1,71 +0,0 @@ -DESCRIPTION > - - Calculates repository-level contributions outside work hours health score. - - Returns percentage of contributions outside work hours and benchmark (0-5) per repository. - - Lower percentage (more during work hours) scores higher. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Optional DateTime filter - - `endDate`: Optional DateTime filter - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_contributions_outside_work_hours_score -SQL > - % - {% if defined(repoUrl) %} - SELECT - channel, - round( - (100. * countIf((weekday >= 6) OR (two_hours_block >= 18) OR (two_hours_block < 8))) - / count(id) - ) AS contributionsOutsideWorkHours - FROM contributions_with_local_time_ds - WHERE - channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(startDate) %} - AND timestamp - > {{ DateTime(startDate, description="Filter after date", required=False) }} - {% end %} - {% if defined(endDate) %} - AND timestamp - < {{ DateTime(endDate, description="Filter before date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT - channel, - round( - (100. * countIf((weekday >= 6) OR (two_hours_block >= 18) OR (two_hours_block < 8))) - / count(id) - ) AS contributionsOutsideWorkHours - FROM contributions_with_local_time_ds - WHERE - timestamp >= toStartOfDay(now() - toIntervalDay(365)) - AND timestamp < toStartOfDay(now() + toIntervalDay(1)) - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - -NODE health_score_contributions_outside_work_hours_benchmark -SQL > - % - SELECT - channel, - contributionsOutsideWorkHours, - CASE - WHEN contributionsOutsideWorkHours >= 75 - THEN 0 - WHEN contributionsOutsideWorkHours BETWEEN 50 AND 74 - THEN 1 - WHEN contributionsOutsideWorkHours BETWEEN 40 AND 49 - THEN 2 - WHEN contributionsOutsideWorkHours BETWEEN 30 AND 39 - THEN 3 - WHEN contributionsOutsideWorkHours BETWEEN 20 AND 29 - THEN 4 - WHEN contributionsOutsideWorkHours BETWEEN 0 AND 19 - THEN 5 - ELSE 0 - END AS contributionsOutsideWorkHoursBenchmark - FROM repo_health_score_contributions_outside_work_hours_score diff --git a/services/libs/tinybird/pipes/repo_health_score_copy.pipe b/services/libs/tinybird/pipes/repo_health_score_copy.pipe deleted file mode 100644 index 218b147380..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_copy.pipe +++ /dev/null @@ -1,140 +0,0 @@ -NODE repo_health_score_copy_repos -DESCRIPTION > - Returns enabled, non-excluded repository URLs linked to insights projects - -SQL > - SELECT r.url AS channel - FROM repositories r FINAL - WHERE r.enabled = true AND r.excluded = false AND isNull (r.deletedAt) AND r.insightsProjectId != '' - -NODE repo_health_score_copy_data -DESCRIPTION > - Join all metrics per repository from separate health score pipes - -SQL > - SELECT - repos.channel AS channel, - COALESCE(ac.activeContributors, 0) AS activeContributors, - COALESCE(ac.activeContributorsBenchmark, 0) AS activeContributorsBenchmark, - COALESCE(cd.contributorDependencyCount, 0) AS contributorDependencyCount, - COALESCE(cd.contributorDependencyPercentage, 0) AS contributorDependencyPercentage, - COALESCE(cd.contributorDependencyBenchmark, 0) AS contributorDependencyBenchmark, - COALESCE(od.organizationDependencyCount, 0) AS organizationDependencyCount, - COALESCE(od.organizationDependencyPercentage, 0) AS organizationDependencyPercentage, - COALESCE(od.organizationDependencyBenchmark, 0) AS organizationDependencyBenchmark, - COALESCE(ret.retentionRate, 0) AS retentionRate, - COALESCE(ret.retentionBenchmark, 0) AS retentionBenchmark, - COALESCE(st.stars, 0) AS stars, - COALESCE(st.starsBenchmark, 0) AS starsBenchmark, - COALESCE(fk.forks, 0) AS forks, - COALESCE(fk.forksBenchmark, 0) AS forksBenchmark, - ir.issueResolution AS issueResolution, - ir.issueResolutionBenchmark AS issueResolutionBenchmark, - COALESCE(pr.pullRequests, 0) AS pullRequests, - COALESCE(pr.pullRequestsBenchmark, 0) AS pullRequestsBenchmark, - mlt.mergeLeadTime AS mergeLeadTime, - mlt.mergeLeadTimeBenchmark AS mergeLeadTimeBenchmark, - COALESCE(ad.activeDaysCount, 0) AS activeDaysCount, - COALESCE(ad.activeDaysBenchmark, 0) AS activeDaysBenchmark, - COALESCE(owh.contributionsOutsideWorkHours, 0) AS contributionsOutsideWorkHours, - COALESCE( - owh.contributionsOutsideWorkHoursBenchmark, 0 - ) AS contributionsOutsideWorkHoursBenchmark, - sec.securityPercentage AS securityPercentage - FROM repo_health_score_copy_repos AS repos - LEFT JOIN repo_health_score_active_contributors AS ac ON repos.channel = ac.channel - LEFT JOIN repo_health_score_contributor_dependency AS cd ON repos.channel = cd.channel - LEFT JOIN repo_health_score_organization_dependency AS od ON repos.channel = od.channel - LEFT JOIN repo_health_score_retention AS ret ON repos.channel = ret.channel - LEFT JOIN repo_health_score_stars AS st ON repos.channel = st.channel - LEFT JOIN repo_health_score_forks AS fk ON repos.channel = fk.channel - LEFT JOIN repo_health_score_issues_resolution AS ir ON repos.channel = ir.channel - LEFT JOIN repo_health_score_pull_requests AS pr ON repos.channel = pr.channel - LEFT JOIN repo_health_score_merge_lead_time AS mlt ON repos.channel = mlt.channel - LEFT JOIN repo_health_score_active_days AS ad ON repos.channel = ad.channel - LEFT JOIN repo_health_score_contributions_outside_work_hours AS owh ON repos.channel = owh.channel - LEFT JOIN repo_health_score_security AS sec ON repos.channel = sec.channel - -NODE repo_health_score_copy_result -DESCRIPTION > - Compute final health score percentages per repository - -SQL > - WITH - arrayFilter( - x -> x >= 0, - [ - activeContributorsBenchmark, - contributorDependencyBenchmark, - organizationDependencyBenchmark, - retentionBenchmark - ] - ) AS contributorBenchmarks, - arrayFilter(x -> x >= 0, [starsBenchmark, forksBenchmark]) AS popularityBenchmarks, - arrayFilter( - x -> x >= 0, - [ - COALESCE(issueResolutionBenchmark, -1), - pullRequestsBenchmark, - COALESCE(mergeLeadTimeBenchmark, -1), - activeDaysBenchmark, - contributionsOutsideWorkHoursBenchmark - ] - ) AS developmentBenchmarks - SELECT - channel, - activeContributors, - activeContributorsBenchmark, - contributorDependencyCount, - contributorDependencyPercentage, - contributorDependencyBenchmark, - organizationDependencyCount, - organizationDependencyPercentage, - organizationDependencyBenchmark, - retentionRate, - retentionBenchmark, - stars, - starsBenchmark, - forks, - forksBenchmark, - issueResolution, - COALESCE(issueResolutionBenchmark, 0) AS issueResolutionBenchmark, - pullRequests, - pullRequestsBenchmark, - mergeLeadTime, - COALESCE(mergeLeadTimeBenchmark, 0) AS mergeLeadTimeBenchmark, - activeDaysCount, - activeDaysBenchmark, - contributionsOutsideWorkHours, - contributionsOutsideWorkHoursBenchmark, - securityPercentage, - round( - 100.0 - * arraySum(contributorBenchmarks) - / if(length(contributorBenchmarks) = 0, 1, 5 * length(contributorBenchmarks)) - ) AS contributorPercentage, - round( - 100.0 - * arraySum(popularityBenchmarks) - / if(length(popularityBenchmarks) = 0, 1, 5 * length(popularityBenchmarks)) - ) AS popularityPercentage, - round( - 100.0 - * arraySum(developmentBenchmarks) - / if(length(developmentBenchmarks) = 0, 1, 5 * length(developmentBenchmarks)) - ) AS developmentPercentage, - round( - ( - contributorPercentage - + popularityPercentage - + developmentPercentage - + if(isNotNull(securityPercentage), securityPercentage, 0) - ) - / if(isNotNull(securityPercentage), 4, 3) - ) AS overallScore - FROM repo_health_score_copy_data - -TYPE COPY -TARGET_DATASOURCE repo_health_score_copy_ds -COPY_MODE replace -COPY_SCHEDULE 50 1 * * * diff --git a/services/libs/tinybird/pipes/repo_health_score_forks.pipe b/services/libs/tinybird/pipes/repo_health_score_forks.pipe deleted file mode 100644 index 353363a915..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_forks.pipe +++ /dev/null @@ -1,58 +0,0 @@ -DESCRIPTION > - - Calculates repository-level forks health score. - - Returns fork count and benchmark (0-5) per repository. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Optional DateTime filter - - `endDate`: Optional DateTime filter - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_forks_score -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, count() AS forks - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - type = 'fork' - AND channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(startDate) %} - AND timestamp - > {{ DateTime(startDate, description="Filter after date", required=False) }} - {% end %} - {% if defined(endDate) %} - AND timestamp - < {{ DateTime(endDate, description="Filter before date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT channel, count() AS forks - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE type = 'fork' AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - -NODE health_score_forks_benchmark -SQL > - % - SELECT - channel, - forks, - CASE - WHEN forks BETWEEN 0 AND 4 - THEN 0 - WHEN forks BETWEEN 5 AND 9 - THEN 1 - WHEN forks BETWEEN 10 AND 19 - THEN 2 - WHEN forks BETWEEN 20 AND 39 - THEN 3 - WHEN forks BETWEEN 40 AND 79 - THEN 4 - WHEN forks >= 80 - THEN 5 - ELSE 0 - END AS forksBenchmark - FROM repo_health_score_forks_score diff --git a/services/libs/tinybird/pipes/repo_health_score_issues_resolution.pipe b/services/libs/tinybird/pipes/repo_health_score_issues_resolution.pipe deleted file mode 100644 index 8e472263df..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_issues_resolution.pipe +++ /dev/null @@ -1,62 +0,0 @@ -DESCRIPTION > - - Calculates repository-level issue resolution health score. - - Returns average days to close issues and benchmark (0-5) per repository. - - Queries `issues_analyzed` directly for optimal performance. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Optional DateTime filter for issues opened after timestamp - - `endDate`: Optional DateTime filter for issues opened before timestamp - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_issues_resolution_score -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, round(avg(closedInSeconds) / (60 * 60 * 24)) AS issueResolution - FROM issues_analyzed - WHERE - channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND closedAt IS NOT NULL - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(startDate) %} - AND openedAt - > {{ DateTime(startDate, description="Filter after date", required=False) }} - {% end %} - {% if defined(endDate) %} - AND openedAt < {{ DateTime(endDate, description="Filter before date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT channel, round(avg(closedInSeconds) / (60 * 60 * 24)) AS issueResolution - FROM issues_analyzed - WHERE - openedAt >= toStartOfDay(now()) - INTERVAL 365 DAY - AND openedAt < toStartOfDay(now()) + INTERVAL 1 DAY - AND closedAt IS NOT NULL - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - -NODE health_score_issues_resolution_benchmark -SQL > - % - SELECT - channel, - issueResolution, - CASE - WHEN issueResolution >= 61 - THEN 0 - WHEN issueResolution BETWEEN 51 AND 60 - THEN 1 - WHEN issueResolution BETWEEN 36 AND 50 - THEN 2 - WHEN issueResolution BETWEEN 22 AND 35 - THEN 3 - WHEN issueResolution BETWEEN 8 AND 21 - THEN 4 - WHEN issueResolution BETWEEN 0 AND 7 - THEN 5 - ELSE 0 - END AS issueResolutionBenchmark - FROM repo_health_score_issues_resolution_score diff --git a/services/libs/tinybird/pipes/repo_health_score_merge_lead_time.pipe b/services/libs/tinybird/pipes/repo_health_score_merge_lead_time.pipe deleted file mode 100644 index b3e48c194d..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_merge_lead_time.pipe +++ /dev/null @@ -1,60 +0,0 @@ -DESCRIPTION > - - Calculates repository-level merge lead time health score. - - Returns average days to merge PRs and benchmark (0-5) per repository. - - Queries `pull_requests_analyzed` for optimal performance. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Optional DateTime filter for PRs opened after timestamp - - `endDate`: Optional DateTime filter for PRs opened before timestamp - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_merge_lead_time_score -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, round(avg(dateDiff('day', openedAt, mergedAt))) AS mergeLeadTime - FROM pull_requests_analyzed - WHERE - channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(startDate) %} - AND openedAt - > {{ DateTime(startDate, description="Filter after date", required=False) }} - {% end %} - {% if defined(endDate) %} - AND openedAt < {{ DateTime(endDate, description="Filter before date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT channel, round(avg(dateDiff('day', openedAt, mergedAt))) AS mergeLeadTime - FROM pull_requests_analyzed - WHERE - openedAt >= toStartOfDay(now() - toIntervalDay(365)) - AND openedAt < toStartOfDay(now() + toIntervalDay(1)) - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - -NODE health_score_merge_lead_time_benchmark -SQL > - % - SELECT - channel, - mergeLeadTime, - CASE - WHEN mergeLeadTime >= 30 - THEN 0 - WHEN mergeLeadTime BETWEEN 21 AND 30 - THEN 1 - WHEN mergeLeadTime BETWEEN 15 AND 20 - THEN 2 - WHEN mergeLeadTime BETWEEN 7 AND 14 - THEN 3 - WHEN mergeLeadTime BETWEEN 3 AND 6 - THEN 4 - WHEN mergeLeadTime BETWEEN 0 AND 2 - THEN 5 - ELSE 0 - END AS mergeLeadTimeBenchmark - FROM repo_health_score_merge_lead_time_score diff --git a/services/libs/tinybird/pipes/repo_health_score_pull_requests.pipe b/services/libs/tinybird/pipes/repo_health_score_pull_requests.pipe deleted file mode 100644 index 1a405d0c25..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_pull_requests.pipe +++ /dev/null @@ -1,70 +0,0 @@ -DESCRIPTION > - - Calculates repository-level pull request activity health score. - - Returns PR count and benchmark (0-5) per repository for the last 365 days. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Optional DateTime filter - - `endDate`: Optional DateTime filter - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_pull_requests_score -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, count() AS pullRequests - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - ( - type = 'pull_request-opened' - OR type = 'merge_request-opened' - OR type = 'changeset-created' - ) - AND channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(startDate) %} - AND timestamp - > {{ DateTime(startDate, description="Filter after date", required=False) }} - {% end %} - {% if defined(endDate) %} - AND timestamp - < {{ DateTime(endDate, description="Filter before date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT channel, count() AS pullRequests - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - ( - type = 'pull_request-opened' - OR type = 'merge_request-opened' - OR type = 'changeset-created' - ) - AND timestamp >= toStartOfDay(now() - toIntervalDay(365)) - AND timestamp < toStartOfDay(now() + toIntervalDay(1)) - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - -NODE health_score_pull_requests_benchmark -SQL > - % - SELECT - channel, - pullRequests, - CASE - WHEN pullRequests BETWEEN 0 AND 1 - THEN 0 - WHEN pullRequests BETWEEN 2 AND 3 - THEN 1 - WHEN pullRequests BETWEEN 4 AND 7 - THEN 2 - WHEN pullRequests BETWEEN 8 AND 15 - THEN 3 - WHEN pullRequests BETWEEN 16 AND 30 - THEN 4 - WHEN pullRequests >= 31 - THEN 5 - ELSE 0 - END AS pullRequestsBenchmark - FROM repo_health_score_pull_requests_score diff --git a/services/libs/tinybird/pipes/repo_health_score_retention.pipe b/services/libs/tinybird/pipes/repo_health_score_retention.pipe deleted file mode 100644 index d3e24eaf18..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_retention.pipe +++ /dev/null @@ -1,133 +0,0 @@ -DESCRIPTION > - - Calculates repository-level contributor retention health score. - - Returns retention rate (percentage of previous quarter contributors active in current quarter) and benchmark (0-5). - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `endDate`: Optional DateTime filter to define the quarter boundary - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_retention_current_quarter -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, groupUniqArray(memberId) AS currentQuarterMembers - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - memberId != '' - AND channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered) - {% if defined(endDate) %} - AND timestamp >= toStartOfQuarter( - parseDateTimeBestEffort( - {{ DateTime(endDate, description="Filter before date", required=False) }} - ) - - INTERVAL 1 QUARTER - ) - AND timestamp < toStartOfQuarter( - parseDateTimeBestEffort( - {{ DateTime(endDate, description="Filter before date", required=False) }} - ) - ) - {% else %} - AND timestamp >= toStartOfQuarter(now() - INTERVAL 1 QUARTER) - AND timestamp < toStartOfQuarter(now()) - {% end %} - GROUP BY channel - {% else %} - SELECT channel, groupUniqArray(memberId) AS currentQuarterMembers - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - memberId != '' - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered) - AND timestamp >= toStartOfQuarter(now() - INTERVAL 1 QUARTER) - AND timestamp < toStartOfQuarter(now()) - GROUP BY channel - {% end %} - -NODE repo_health_score_retention_previous_quarter -SQL > - % - {% if defined(repoUrl) %} - SELECT channel, groupUniqArray(memberId) AS previousQuarterMembers - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - memberId != '' - AND channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered) - {% if defined(endDate) %} - AND timestamp >= toStartOfQuarter( - parseDateTimeBestEffort( - {{ DateTime(endDate, description="Filter before date", required=False) }} - ) - - INTERVAL 2 QUARTER - ) - AND timestamp < toStartOfQuarter( - parseDateTimeBestEffort( - {{ DateTime(endDate, description="Filter before date", required=False) }} - ) - - INTERVAL 1 QUARTER - ) - {% else %} - AND timestamp >= toStartOfQuarter(now() - INTERVAL 2 QUARTER) - AND timestamp < toStartOfQuarter(now() - INTERVAL 1 QUARTER) - {% end %} - GROUP BY channel - {% else %} - SELECT channel, groupUniqArray(memberId) AS previousQuarterMembers - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - memberId != '' - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered) - AND timestamp >= toStartOfQuarter(now() - INTERVAL 2 QUARTER) - AND timestamp < toStartOfQuarter(now() - INTERVAL 1 QUARTER) - GROUP BY channel - {% end %} - -NODE health_score_retention_counts -SQL > - % - SELECT - cur.channel AS channel, - if( - length(coalesce(prev.previousQuarterMembers, [])) > 0, - round( - 100 * length( - arrayIntersect( - coalesce(cur.currentQuarterMembers, []), - coalesce(prev.previousQuarterMembers, []) - ) - ) - / length(coalesce(prev.previousQuarterMembers, [])) - ), - 0 - ) AS retentionRate - FROM repo_health_score_retention_current_quarter AS cur - LEFT JOIN repo_health_score_retention_previous_quarter AS prev USING (channel) - -NODE health_score_retention_benchmark -SQL > - % - SELECT - channel, - retentionRate, - CASE - WHEN retentionRate BETWEEN 0 AND 2 - THEN 0 - WHEN retentionRate BETWEEN 3 AND 5 - THEN 1 - WHEN retentionRate BETWEEN 6 AND 9 - THEN 2 - WHEN retentionRate BETWEEN 10 AND 14 - THEN 3 - WHEN retentionRate BETWEEN 15 AND 19 - THEN 4 - WHEN retentionRate >= 20 - THEN 5 - ELSE 0 - END AS retentionBenchmark - FROM health_score_retention_counts diff --git a/services/libs/tinybird/pipes/repo_health_score_security.pipe b/services/libs/tinybird/pipes/repo_health_score_security.pipe deleted file mode 100644 index 1fe488d3fe..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_security.pipe +++ /dev/null @@ -1,45 +0,0 @@ -DESCRIPTION > - - Calculates repository-level security health score. - - Returns security assessment pass rate percentage per repository. - - Uses `security_deduplicated_merged_ds` for security evaluation data. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_security_check_pass_rate -SQL > - % - SELECT - repo, - category, - arrayFilter( - x -> x['requirementId'] not in ('OSPS-AC-01.01'), assessments - ) as filteredAssessments, - length(arrayFilter(x -> x['result'] = 'Failed', filteredAssessments)) AS failedAssessments, - length(arrayFilter(x -> x['result'] = 'Passed', filteredAssessments)) AS passedAssessments - FROM security_deduplicated_merged_ds - WHERE - category NOT IN ('Documentation', 'Vulnerability Management') AND repo != '' - {% if defined(repoUrl) %} - AND repo = {{ String(repoUrl, description="Repository URL", required=False) }} - {% end %} - -NODE repo_health_score_security_category -SQL > - SELECT - repo, - category, - sum(failedAssessments) AS failed, - sum(passedAssessments) AS passed, - sum(failedAssessments + passedAssessments) AS total, - if(total = 0, 0, round(100 * (passed / total))) AS percentage - FROM repo_health_score_security_check_pass_rate - WHERE repo != '' - GROUP BY repo, category - -NODE repo_health_score_security_score -SQL > - SELECT repo AS channel, round(avg(percentage)) AS securityPercentage - FROM repo_health_score_security_category - GROUP BY repo diff --git a/services/libs/tinybird/pipes/repo_health_score_stars.pipe b/services/libs/tinybird/pipes/repo_health_score_stars.pipe deleted file mode 100644 index a2176e4ba7..0000000000 --- a/services/libs/tinybird/pipes/repo_health_score_stars.pipe +++ /dev/null @@ -1,112 +0,0 @@ -DESCRIPTION > - - Calculates repository-level stars health score. - - Returns star count and benchmark (0-5) per repository. - - Parameters: - - `repoUrl`: Optional repository URL for single-repo mode - - `startDate`: Unused - stars is a cumulative total, not a period count - - `endDate`: Optional DateTime, returns cumulative stars as of this date - -TAGS "Repository health", "Metrics" - -NODE repo_health_score_stars_score -SQL > - % - SELECT channel, sum(stars) AS stars - FROM - ( - {% if defined(repoUrl) %} - SELECT r.url AS channel, toUInt64(s.starCount) AS stars - FROM - ( - SELECT repositoryId, argMax(starCount, (capturedAt, updatedAt)) AS starCount - FROM repositoryStarSnapshots - WHERE - repositoryId IN ( - SELECT r2.id - FROM repositories r2 FINAL - WHERE - isNull (r2.deletedAt) - AND r2.enabled = true - AND r2.excluded = false - AND lower(r2.url) = lower( - {{ - String( - repoUrl, description="Repository URL", required=False - ) - }} - ) - ) - {% if defined(endDate) %} - AND capturedAt - <= {{ - DateTime( - endDate, description="Snapshot as of date", required=False - ) - }} - {% end %} - GROUP BY repositoryId - ) s - INNER JOIN repositories r FINAL ON r.id = s.repositoryId - WHERE - isNull (r.deletedAt) - AND r.enabled = true - AND r.excluded = false - AND lower(r.url) - = lower({{ String(repoUrl, description="Repository URL", required=False) }}) - UNION ALL - SELECT channel, count() AS stars - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - type = 'star' - AND platform != 'github' - AND channel = {{ String(repoUrl, description="Repository URL", required=False) }} - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - {% if defined(endDate) %} - AND timestamp - <= {{ DateTime(endDate, description="Cumulative as of date", required=False) }} - {% end %} - GROUP BY channel - {% else %} - SELECT r.url AS channel, toUInt64(s.starCount) AS stars - FROM - ( - SELECT repositoryId, argMax(starCount, (capturedAt, updatedAt)) AS starCount - FROM repositoryStarSnapshots - GROUP BY repositoryId - ) s - INNER JOIN repositories r FINAL ON r.id = s.repositoryId - WHERE isNull (r.deletedAt) AND r.enabled = true AND r.excluded = false - UNION ALL - SELECT channel, count() AS stars - FROM activityRelations_deduplicated_cleaned_bucket_union - WHERE - type = 'star' - AND platform != 'github' - AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded) - GROUP BY channel - {% end %} - ) - GROUP BY channel - -NODE health_score_stars_benchmark -SQL > - % - SELECT - channel, - stars, - CASE - WHEN stars BETWEEN 0 AND 9 - THEN 0 - WHEN stars BETWEEN 10 AND 49 - THEN 1 - WHEN stars BETWEEN 50 AND 199 - THEN 2 - WHEN stars BETWEEN 200 AND 499 - THEN 3 - WHEN stars BETWEEN 500 AND 999 - THEN 4 - WHEN stars >= 1000 - THEN 5 - ELSE 0 - END AS starsBenchmark - FROM repo_health_score_stars_score