Skip to content

Commit 9c0f754

Browse files
authored
fix: collection dev-velocity scope + repo contributor count inflation (IN-1195) (#4361)
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent 2fe97e5 commit 9c0f754

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

services/libs/tinybird/pipes/issues_average_resolve_velocity.pipe

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ DESCRIPTION >
44
- Only includes issues that have been closed (`isNotNull(closedAt)`) to ensure accurate velocity calculations.
55
- Queries `issues_analyzed` directly for optimal performance using sorting key on `segmentId, channel, openedAt`.
66
- Primary use case: displaying average issue resolution time metrics in development health dashboards.
7+
- The pipe scopes data either to a single project (via `segments_filtered`) or to every project in a
8+
collection (via `segments_filtered_by_collection`). Exactly one of `project`/`collectionSlug` must be given.
79
- Parameters:
8-
- `project`: Required string for project slug (e.g., 'k8s', 'tensorflow') - inherited from `segments_filtered`
10+
- `project`: Project slug (e.g., 'k8s', 'tensorflow') - inherited from `segments_filtered`. Required unless `collectionSlug` is given.
11+
- `collectionSlug`: Collection slug (e.g., 'cncf') - inherited from `segments_filtered_by_collection`. Required unless `project` is given.
912
- `repos`: Optional array of repository URLs for filtering (e.g., ['https://github.com/kubernetes/kubernetes'])
1013
- `startDate`: Optional DateTime filter for issues opened after timestamp (e.g., '2024-01-01 00:00:00')
1114
- `endDate`: Optional DateTime filter for issues opened before timestamp (e.g., '2024-12-31 23:59:59')
@@ -17,7 +20,10 @@ SQL >
1720
SELECT round(avg(closedInSeconds)) AS "averageIssueResolveVelocitySeconds"
1821
FROM issues_analyzed
1922
WHERE
20-
segmentId = (SELECT segmentId FROM segments_filtered) AND isNotNull(closedAt)
23+
{% if defined(collectionSlug) %}
24+
segmentId IN (SELECT segmentId FROM segments_filtered_by_collection)
25+
{% else %} segmentId = (SELECT segmentId FROM segments_filtered)
26+
{% end %} AND isNotNull(closedAt)
2127
{% if defined(repos) %}
2228
AND channel
2329
IN {{ Array(repos, 'String', description="Filter activity repo list", required=False) }}

services/libs/tinybird/pipes/pull_requests_average_resolve_velocity.pipe

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ DESCRIPTION >
55
- Excludes Gerrit platform as it uses a different workflow model.
66
- Queries `pull_requests_analyzed` directly for optimal performance using sorting key on `segmentId, channel, openedAt`.
77
- Primary use case: displaying average PR resolution time metrics in development health dashboards.
8+
- The pipe scopes data either to a single project (via `segments_filtered`) or to every project in a
9+
collection (via `segments_filtered_by_collection`). Exactly one of `project`/`collectionSlug` must be given.
810
- Parameters:
9-
- `project`: Required string for project slug (e.g., 'k8s', 'tensorflow') - inherited from `segments_filtered`
11+
- `project`: Project slug (e.g., 'k8s', 'tensorflow') - inherited from `segments_filtered`. Required unless `collectionSlug` is given.
12+
- `collectionSlug`: Collection slug (e.g., 'cncf') - inherited from `segments_filtered_by_collection`. Required unless `project` is given.
1013
- `repos`: Optional array of repository URLs for filtering (e.g., ['https://github.com/kubernetes/kubernetes'])
1114
- `startDate`: Optional DateTime filter for PRs opened after timestamp (e.g., '2024-01-01 00:00:00')
1215
- `endDate`: Optional DateTime filter for PRs opened before timestamp (e.g., '2024-12-31 23:59:59')
@@ -18,10 +21,10 @@ SQL >
1821
SELECT round(avg(resolvedInSeconds)) AS "averagePullRequestResolveVelocitySeconds"
1922
FROM pull_requests_analyzed
2023
WHERE
21-
segmentId = (SELECT segmentId FROM segments_filtered)
22-
AND isNotNull(resolvedAt)
23-
AND resolvedInSeconds > 0
24-
AND platform != 'gerrit'
24+
{% if defined(collectionSlug) %}
25+
segmentId IN (SELECT segmentId FROM segments_filtered_by_collection)
26+
{% else %} segmentId = (SELECT segmentId FROM segments_filtered)
27+
{% end %} AND isNotNull(resolvedAt) AND resolvedInSeconds > 0 AND platform != 'gerrit'
2528
{% if defined(repos) %}
2629
AND channel
2730
IN {{ Array(repos, 'String', description="Filter activity repo list", required=False) }}

services/libs/tinybird/pipes/repositories_populated_copy.pipe

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ SQL >
99

1010
NODE repositories_populated_copy_contributor_org_counts
1111
DESCRIPTION >
12-
Calculate contributor and organization counts per repository (channel)
12+
Calculate contributor and organization counts per repository (channel).
13+
Excludes 'star' and 'fork' activity: stargazers/forkers are engagement, not contributors,
14+
and counting them inflated contributorCount massively for popular repos (e.g. OpenClaw showed
15+
483K where the true contributor count is ~46K - 404K of those were stargazers). This mirrors
16+
the "contributions only" semantics the widget pipes use via onlyContributions/activityTypes_filtered.
1317

1418
SQL >
1519
SELECT
1620
channel,
1721
uniq(CASE WHEN memberId != '' THEN memberId ELSE NULL END) AS contributorCount,
1822
uniq(CASE WHEN organizationId != '' THEN organizationId ELSE NULL END) AS organizationCount
1923
FROM activityRelations_deduplicated_cleaned_bucket_union
24+
WHERE type NOT IN ('star', 'fork')
2025
GROUP BY channel
2126

2227
NODE repositories_populated_copy_first_commit

0 commit comments

Comments
 (0)