Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SQL >
memberId != ''
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -30,7 +30,7 @@ SQL >
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 = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId
{% end %}

Expand Down
4 changes: 2 additions & 2 deletions services/libs/tinybird/pipes/health_score_active_days.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SQL >
FROM activityRelations_bucket_routing
WHERE
segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -23,7 +23,7 @@ SQL >
WHERE
timestamp >= toStartOfDay(now() - toIntervalDay(365))
AND timestamp < toStartOfDay(now())
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId
{% end %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SQL >
1 = 1
{% if defined(project) %}
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -25,7 +25,7 @@ SQL >
{% else %}
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% end %}
GROUP BY segmentId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SQL >
memberId != ''
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -28,7 +28,7 @@ SQL >
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
AND timestamp >= toStartOfDay(now() - INTERVAL 365 DAY)
AND timestamp < toStartOfDay(now() + INTERVAL 1 DAY)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId, memberId
ORDER by contributionCount DESC
{% end %}
Expand Down
4 changes: 2 additions & 2 deletions services/libs/tinybird/pipes/health_score_forks.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SQL >
WHERE
type = 'fork'
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -24,7 +24,7 @@ SQL >
{% else %}
SELECT segmentId, count() AS forks
FROM activityRelations_deduplicated_cleaned_bucket_union
WHERE type = 'fork' AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
WHERE type = 'fork' AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId
{% end %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SQL >
WHERE
segmentId = (SELECT segmentId FROM segments_filtered)
AND closedAt IS NOT NULL
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND openedAt
Expand All @@ -34,7 +34,7 @@ SQL >
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 = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId
{% end %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SQL >
1 = 1
{% if defined(project) %}
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND openedAt
Expand All @@ -22,7 +22,7 @@ SQL >
{% else %}
AND openedAt >= toStartOfDay(now() - toIntervalDay(365))
AND openedAt < toStartOfDay(now() + toIntervalDay(1))
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% end %}
GROUP BY segmentId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SQL >
organizationId != ''
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -27,7 +27,7 @@ SQL >
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
AND timestamp >= toStartOfDay(now() - INTERVAL 365 DAY)
AND timestamp < toStartOfDay(now() + INTERVAL 1 DAY)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId, organizationId
{% end %}

Expand Down
4 changes: 2 additions & 2 deletions services/libs/tinybird/pipes/health_score_pull_requests.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SQL >
OR type = 'changeset-created'
)
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -36,7 +36,7 @@ SQL >
)
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId
{% end %}

Expand Down
8 changes: 4 additions & 4 deletions services/libs/tinybird/pipes/health_score_retention.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SQL >
WHERE
memberId != ''
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(endDate) %}
AND timestamp >= toStartOfQuarter(
Expand All @@ -30,7 +30,7 @@ SQL >
SELECT segmentId, groupUniqArray(memberId) AS currentQuarterMembers
FROM activityRelations_deduplicated_cleaned_bucket_union
WHERE
memberId != '' AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
memberId != '' AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(endDate) %}
AND timestamp >= toStartOfQuarter(
parseDateTimeBestEffort(
Expand Down Expand Up @@ -59,7 +59,7 @@ SQL >
WHERE
memberId != ''
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(endDate) %}
AND timestamp >= toStartOfQuarter(
parseDateTimeBestEffort(
Expand All @@ -82,7 +82,7 @@ SQL >
SELECT segmentId, groupUniqArray(memberId) AS previousQuarterMembers
FROM activityRelations_deduplicated_cleaned_bucket_union
WHERE
memberId != '' AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
memberId != '' AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(endDate) %}
AND timestamp >= toStartOfQuarter(
parseDateTimeBestEffort(
Expand Down
4 changes: 2 additions & 2 deletions services/libs/tinybird/pipes/health_score_stars.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SQL >
WHERE
type = 'star'
AND segmentId = (SELECT segmentId FROM segments_filtered)
AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
{% if defined(startDate) %}
AND timestamp
Expand All @@ -24,7 +24,7 @@ SQL >
{% else %}
SELECT segmentId, count() AS stars
FROM activityRelations_deduplicated_cleaned_bucket_union
WHERE type = 'star' AND channel NOT IN (SELECT channel FROM repos_to_channels(excluded = True))
WHERE type = 'star' AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
GROUP BY segmentId
{% end %}

Expand Down
62 changes: 62 additions & 0 deletions services/libs/tinybird/pipes/repos_to_channels_excluded.pipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
DESCRIPTION >
- `repos_to_channels_excluded.pipe` expands excluded repository URLs to all possible activity channel formats.
- For Gerrit repos, generates both the original URL and the /q/project: variant since activity channels use this format.
- Non-Gerrit repos are passed through unchanged.
- Used by activity filtering pipes to build exclusion filters for channels that belong to excluded repositories.
- Response: `channel` - all possible channel URL formats for excluded repos

TAGS "Repository URLs", "Gerrit"

NODE repos_to_expand
DESCRIPTION >
Get excluded repository URLs to expand

SQL >
SELECT url FROM repositories FINAL WHERE isNull (deletedAt) AND enabled = true AND excluded = true

NODE gerrit_repos
DESCRIPTION >
Identify Gerrit repositories by joining with integrations table

SQL >
SELECT r.url
FROM repositories r FINAL
JOIN integrations i FINAL ON r.sourceIntegrationId = i.id
WHERE i.platform = 'gerrit' AND isNull (r.deletedAt) AND r.url IN (SELECT url FROM repos_to_expand)

NODE expanded_urls
DESCRIPTION >
Output original URLs plus Gerrit channel variants

SQL >
-- Original URLs (all excluded repos)
SELECT url AS channel
FROM repos_to_expand
UNION ALL
-- Gerrit channel variants: insert q/project: after the base path
SELECT
CASE
-- Pattern: https://host/r/{project} → https://host/r/q/project:{project}
WHEN position(url, '/r/') > 0
THEN replaceOne(url, '/r/', '/r/q/project:')
-- Pattern: https://host/gerrit/{project} → https://host/gerrit/q/project:{project}
WHEN position(url, '/gerrit/') > 0
THEN replaceOne(url, '/gerrit/', '/gerrit/q/project:')
-- Pattern: https://host/{project} → https://host/q/project:{project}
ELSE
concat(
protocol(url),
'://',
domain(url),
'/q/project:',
if(path(url) = '/', '', substring(path(url), 2))
)
END AS channel
FROM gerrit_repos

NODE channels_deduplicated
DESCRIPTION >
Final deduplicated list of all possible channel URLs for excluded repos

SQL >
SELECT DISTINCT channel FROM expanded_urls