Skip to content

Commit 6f812c7

Browse files
committed
fix: reactivate nodes
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent 50a13b2 commit 6f812c7

22 files changed

Lines changed: 820 additions & 0 deletions
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,37 @@
1+
NODE health_score_active_contributors_score
2+
DESCRIPTION >
3+
Returns activeContributors for previous quarter per project
4+
5+
SQL >
6+
%
7+
{% if defined(project) %}
8+
SELECT segmentId, COALESCE(uniq(memberId), 0) AS activeContributors
9+
FROM activityRelations_bucket_routing
10+
WHERE
11+
memberId != ''
12+
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
13+
AND segmentId = (SELECT segmentId FROM segments_filtered)
14+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
15+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
16+
{% if defined(startDate) %}
17+
AND timestamp
18+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
19+
{% end %}
20+
{% if defined(endDate) %}
21+
AND timestamp
22+
< {{ DateTime(endDate, description="Filter before date", required=False) }}
23+
{% end %}
24+
GROUP BY segmentId
25+
{% else %}
26+
SELECT segmentId, COALESCE(uniq(memberId), 0) AS activeContributors
27+
FROM activityRelations_deduplicated_cleaned_bucket_union
28+
WHERE
29+
memberId != ''
30+
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
31+
AND timestamp >= toStartOfQuarter(now() - toIntervalQuarter(1))
32+
AND timestamp < toStartOfQuarter(now())
33+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
34+
GROUP BY segmentId
35+
{% end %}
36+
137
INCLUDE "../includes/health_score_active_contributors.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_active_contributors_score"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1+
NODE health_score_active_days_score
2+
SQL >
3+
%
4+
{% if defined(project) %}
5+
SELECT segmentId, countDistinct(DATE(timestamp)) AS activeDaysCount
6+
FROM activityRelations_bucket_routing
7+
WHERE
8+
segmentId = (SELECT segmentId FROM segments_filtered)
9+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
10+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
11+
{% if defined(startDate) %}
12+
AND timestamp
13+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
14+
{% end %}
15+
{% if defined(endDate) %}
16+
AND timestamp
17+
< {{ DateTime(endDate, description="Filter before date", required=False) }}
18+
{% end %}
19+
GROUP BY segmentId
20+
{% else %}
21+
SELECT segmentId, countDistinct(DATE(timestamp)) AS activeDaysCount
22+
FROM activityRelations_deduplicated_cleaned_bucket_union
23+
WHERE
24+
timestamp >= toStartOfDay(now() - toIntervalDay(365))
25+
AND timestamp < toStartOfDay(now())
26+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
27+
GROUP BY segmentId
28+
{% end %}
29+
130
INCLUDE "../includes/health_score_active_days.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_active_days_score"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1+
NODE health_score_contributions_outside_work_hours_score
2+
SQL >
3+
%
4+
SELECT
5+
segmentId,
6+
round(
7+
(100. * countIf((weekday >= 6) OR (two_hours_block >= 18) OR (two_hours_block < 8)))
8+
/ count(id)
9+
) AS contributionsOutsideWorkHours
10+
FROM contributions_with_local_time_ds AS a
11+
WHERE
12+
1 = 1
13+
{% if defined(project) %}
14+
AND segmentId = (SELECT segmentId FROM segments_filtered)
15+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
16+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
17+
{% if defined(startDate) %}
18+
AND timestamp
19+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
20+
{% end %}
21+
{% if defined(endDate) %}
22+
AND timestamp
23+
< {{ DateTime(endDate, description="Filter before date", required=False) }}
24+
{% end %}
25+
{% else %}
26+
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
27+
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
28+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
29+
{% end %}
30+
GROUP BY segmentId
31+
132
INCLUDE "../includes/health_score_contributions_outside_work_hours.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_contributions_outside_work_hours_score"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1+
NODE health_score_contributor_dependency_contribution_count
2+
SQL >
3+
%
4+
{% if defined(project) %}
5+
SELECT segmentId, memberId, count() AS contributionCount, MIN(timestamp), MAX(timestamp)
6+
FROM activityRelations_bucket_routing
7+
WHERE
8+
memberId != ''
9+
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
10+
AND segmentId = (SELECT segmentId FROM segments_filtered)
11+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
12+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
13+
{% if defined(startDate) %}
14+
AND timestamp
15+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
16+
{% end %}
17+
{% if defined(endDate) %}
18+
AND timestamp
19+
< {{ DateTime(endDate, description="Filter before date", required=False) }}
20+
{% end %}
21+
GROUP BY segmentId, memberId
22+
ORDER by contributionCount DESC
23+
{% else %}
24+
SELECT segmentId, memberId, count() AS contributionCount, MIN(timestamp), MAX(timestamp)
25+
FROM activityRelations_deduplicated_cleaned_bucket_union
26+
WHERE
27+
memberId != ''
28+
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
29+
AND timestamp >= toStartOfDay(now() - INTERVAL 365 DAY)
30+
AND timestamp < toStartOfDay(now() + INTERVAL 1 DAY)
31+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
32+
GROUP BY segmentId, memberId
33+
ORDER by contributionCount DESC
34+
{% end %}
35+
136
INCLUDE "../includes/health_score_contributor_dependency.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_contributor_dependency_contribution_count"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1+
NODE health_score_forks_score
2+
DESCRIPTION >
3+
Returns activeContributors for previous quarter per project
4+
5+
SQL >
6+
%
7+
{% if defined(project) %}
8+
SELECT segmentId, count() AS forks
9+
FROM activityRelations_bucket_routing
10+
WHERE
11+
type = 'fork'
12+
AND segmentId = (SELECT segmentId FROM segments_filtered)
13+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
14+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
15+
{% if defined(startDate) %}
16+
AND timestamp
17+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
18+
{% end %}
19+
{% if defined(endDate) %}
20+
AND timestamp
21+
< {{ DateTime(endDate, description="Filter before date", required=False) }}
22+
{% end %}
23+
GROUP BY segmentId
24+
{% else %}
25+
SELECT segmentId, count() AS forks
26+
FROM activityRelations_deduplicated_cleaned_bucket_union
27+
WHERE type = 'fork' AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
28+
GROUP BY segmentId
29+
{% end %}
30+
131
INCLUDE "../includes/health_score_forks.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_forks_score"

services/libs/tinybird/pipes/health_score_issues_resolution.pipe

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,34 @@ DESCRIPTION >
88
- `startDate`: Optional DateTime filter for issues opened after timestamp
99
- `endDate`: Optional DateTime filter for issues opened before timestamp
1010

11+
NODE health_score_issues_resolution_score
12+
SQL >
13+
%
14+
{% if defined(project) %}
15+
SELECT segmentId, round(avg(closedInSeconds) / (60 * 60 * 24)) AS issueResolution
16+
FROM issues_analyzed
17+
WHERE
18+
segmentId = (SELECT segmentId FROM segments_filtered)
19+
AND closedAt IS NOT NULL
20+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
21+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
22+
{% if defined(startDate) %}
23+
AND openedAt
24+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
25+
{% end %}
26+
{% if defined(endDate) %}
27+
AND openedAt < {{ DateTime(endDate, description="Filter before date", required=False) }}
28+
{% end %}
29+
GROUP BY segmentId
30+
{% else %}
31+
SELECT segmentId, round(avg(closedInSeconds) / (60 * 60 * 24)) AS issueResolution
32+
FROM issues_analyzed
33+
WHERE
34+
openedAt >= toStartOfDay(now()) - INTERVAL 365 DAY
35+
AND openedAt < toStartOfDay(now()) + INTERVAL 1 DAY
36+
AND closedAt IS NOT NULL
37+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
38+
GROUP BY segmentId
39+
{% end %}
40+
1141
INCLUDE "../includes/health_score_issues_resolution.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_issues_resolution_score"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1+
NODE health_score_merge_lead_time_score
2+
DESCRIPTION >
3+
Returns activeContributors for previous quarter per project
4+
5+
SQL >
6+
%
7+
SELECT segmentId, round(avg(dateDiff('day', openedAt, mergedAt))) AS mergeLeadTime
8+
FROM pull_requests_analyzed
9+
WHERE
10+
1 = 1
11+
{% if defined(project) %}
12+
AND segmentId = (SELECT segmentId FROM segments_filtered)
13+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
14+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
15+
{% if defined(startDate) %}
16+
AND openedAt
17+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
18+
{% end %}
19+
{% if defined(endDate) %}
20+
AND openedAt < {{ DateTime(endDate, description="Filter before date", required=False) }}
21+
{% end %}
22+
{% else %}
23+
AND openedAt >= toStartOfDay(now() - toIntervalDay(365))
24+
AND openedAt < toStartOfDay(now() + toIntervalDay(1))
25+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
26+
{% end %}
27+
GROUP BY segmentId
28+
129
INCLUDE "../includes/health_score_merge_lead_time.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_merge_lead_time_score"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1+
NODE health_score_organization_dependency_contribution_count
2+
SQL >
3+
%
4+
{% if defined(project) %}
5+
SELECT segmentId, organizationId, count() AS contributionCount
6+
FROM activityRelations_bucket_routing
7+
WHERE
8+
organizationId != ''
9+
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
10+
AND segmentId = (SELECT segmentId FROM segments_filtered)
11+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
12+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
13+
{% if defined(startDate) %}
14+
AND timestamp
15+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
16+
{% end %}
17+
{% if defined(endDate) %}
18+
AND timestamp
19+
< {{ DateTime(endDate, description="Filter before date", required=False) }}
20+
{% end %}
21+
GROUP BY segmentId, organizationId
22+
{% else %}
23+
SELECT segmentId, organizationId, count() AS contributionCount
24+
FROM activityRelations_deduplicated_cleaned_bucket_union
25+
WHERE
26+
organizationId != ''
27+
AND (type, platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
28+
AND timestamp >= toStartOfDay(now() - INTERVAL 365 DAY)
29+
AND timestamp < toStartOfDay(now() + INTERVAL 1 DAY)
30+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
31+
GROUP BY segmentId, organizationId
32+
{% end %}
33+
134
INCLUDE "../includes/health_score_organization_dependency.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_organization_dependency_contribution_count"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
1+
NODE health_score_pull_requests_score
2+
DESCRIPTION >
3+
Returns activeContributors for previous quarter per project
4+
5+
SQL >
6+
%
7+
{% if defined(project) %}
8+
SELECT segmentId, count() AS pullRequests
9+
FROM activityRelations_bucket_routing
10+
WHERE
11+
(
12+
type = 'pull_request-opened'
13+
OR type = 'merge_request-opened'
14+
OR type = 'changeset-created'
15+
)
16+
AND segmentId = (SELECT segmentId FROM segments_filtered)
17+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
18+
{% if defined(repos) %} AND channel IN (SELECT channel FROM repos_to_channels) {% end %}
19+
{% if defined(startDate) %}
20+
AND timestamp
21+
> {{ DateTime(startDate, description="Filter after date", required=False) }}
22+
{% end %}
23+
{% if defined(endDate) %}
24+
AND timestamp
25+
< {{ DateTime(endDate, description="Filter before date", required=False) }}
26+
{% end %}
27+
GROUP BY segmentId
28+
{% else %}
29+
SELECT segmentId, count() AS pullRequests
30+
FROM activityRelations_deduplicated_cleaned_bucket_union
31+
WHERE
32+
(
33+
type = 'pull_request-opened'
34+
OR type = 'merge_request-opened'
35+
OR type = 'changeset-created'
36+
)
37+
AND timestamp >= toStartOfDay(now() - toIntervalDay(365))
38+
AND timestamp < toStartOfDay(now() + toIntervalDay(1))
39+
AND channel NOT IN (SELECT channel FROM repos_to_channels_excluded)
40+
GROUP BY segmentId
41+
{% end %}
42+
143
INCLUDE "../includes/health_score_pull_requests.incl" "GROUP_COL=segmentId" "SOURCE_NODE=health_score_pull_requests_score"

0 commit comments

Comments
 (0)