Skip to content

Commit be0e659

Browse files
authored
fix: use repos_to_channel for PR & issues (#3810)
1 parent f409683 commit be0e659

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

services/libs/tinybird/pipes/issues_average_resolve_velocity.pipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ SQL >
2121
{% if defined(repos) %}
2222
AND channel
2323
IN {{ Array(repos, 'String', description="Filter activity repo list", required=False) }}
24-
{% else %} AND channel IN (SELECT url FROM repositories FINAL WHERE excluded = false)
24+
{% else %} AND channel IN (SELECT channel FROM repos_to_channels)
2525
{% end %}
2626
{% if defined(startDate) %}
2727
AND openedAt > {{ DateTime(startDate, description="Filter after date", required=False) }}

services/libs/tinybird/pipes/pull_requests_average_resolve_velocity.pipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SQL >
2525
{% if defined(repos) %}
2626
AND channel
2727
IN {{ Array(repos, 'String', description="Filter activity repo list", required=False) }}
28-
{% else %} AND channel IN (SELECT url FROM repositories FINAL WHERE excluded = false)
28+
{% else %} AND channel IN (SELECT channel FROM repos_to_channels)
2929
{% end %}
3030
{% if defined(startDate) %}
3131
AND openedAt > {{ DateTime(startDate, description="Filter after date", required=False) }}

services/libs/tinybird/pipes/pull_requests_filtered.pipe

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ DESCRIPTION >
1212

1313
NODE pull_requests_filtered_0
1414
SQL >
15-
%
1615
SELECT *
1716
FROM pull_requests_analyzed pra
18-
where
17+
WHERE
1918
pra.segmentId = (SELECT segmentId FROM segments_filtered)
20-
{% if defined(repos) %}
21-
AND pra.channel IN (SELECT channel FROM repos_to_channels)
22-
{% else %} AND pra.channel IN (SELECT url FROM repositories FINAL where excluded = false)
23-
{% end %}
19+
AND pra.channel IN (SELECT channel FROM repos_to_channels)

services/libs/tinybird/pipes/repos_to_channels.pipe

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@ DESCRIPTION >
44
- Non-Gerrit repos are passed through unchanged.
55
- Used by activity filtering pipes to match repos against activity channels.
66
- Parameters:
7-
- `repos`: Required array of repository URLs to expand
7+
- `repos`: Optional array of repository URLs to expand. If not provided, defaults to all non-excluded, enabled repositories.
88
- Response: `channel` - all possible channel URL formats for the given repos
99

1010
TAGS "Repository URLs", "Gerrit"
1111

1212
NODE repos_to_expand
1313
DESCRIPTION >
14-
Get repository URLs to expand from repos param
14+
Get repository URLs to expand from repos param, or default to all non-excluded enabled repositories
1515

1616
SQL >
1717
%
18-
SELECT
19-
arrayJoin(
20-
{{ Array(repos, 'String', description="Repository URLs to expand", required=True) }}
21-
) AS url
18+
{% if defined(repos) %}
19+
SELECT
20+
arrayJoin(
21+
{{ Array(repos, 'String', description="Repository URLs to expand", required=False) }}
22+
) AS url
23+
{% else %}
24+
SELECT url
25+
FROM repositories FINAL
26+
WHERE excluded = false AND isNull (deletedAt) AND enabled = true
27+
{% end %}
2228

2329
NODE gerrit_repos
2430
DESCRIPTION >

0 commit comments

Comments
 (0)