Skip to content

Commit 57f7850

Browse files
committed
feat: format
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent a64af87 commit 57f7850

4 files changed

Lines changed: 148 additions & 57 deletions

File tree

services/libs/tinybird/pipes/ai_code_tracker.pipe

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,61 @@ TAGS "Report"
1212
NODE ai_code_tracker_result
1313
DESCRIPTION >
1414
Aggregate pre-computed AI commit counts by tool and time period
15+
1516
SQL >
1617
%
1718
SELECT
1819
toolKey,
1920
multiIf(
20-
toolKey = 'github-copilot', 'GitHub Copilot',
21-
toolKey = 'chatgpt', 'ChatGPT',
22-
toolKey = 'claude', 'Claude',
23-
toolKey = 'cursor', 'Cursor',
24-
toolKey = 'codewhisperer', 'CodeWhisperer',
25-
toolKey = 'gemini', 'Gemini',
26-
toolKey = 'codeium', 'Codeium',
27-
toolKey = 'aider', 'Aider',
28-
toolKey = 'devin', 'Devin',
29-
toolKey = 'tabnine', 'Tabnine',
30-
toolKey = 'other', 'Other AI',
21+
toolKey = 'github-copilot',
22+
'GitHub Copilot',
23+
toolKey = 'chatgpt',
24+
'ChatGPT',
25+
toolKey = 'claude',
26+
'Claude',
27+
toolKey = 'cursor',
28+
'Cursor',
29+
toolKey = 'codewhisperer',
30+
'CodeWhisperer',
31+
toolKey = 'gemini',
32+
'Gemini',
33+
toolKey = 'codeium',
34+
'Codeium',
35+
toolKey = 'aider',
36+
'Aider',
37+
toolKey = 'devin',
38+
'Devin',
39+
toolKey = 'tabnine',
40+
'Tabnine',
41+
toolKey = 'other',
42+
'Other AI',
3143
'Unknown'
3244
) AS toolName,
3345
formatDateTime(
3446
CASE
35-
WHEN {{ String(granularity, description="Time aggregation: monthly or yearly", required=True) }} = 'monthly'
47+
WHEN
48+
{{
49+
String(
50+
granularity,
51+
description="Time aggregation: monthly or yearly",
52+
required=True,
53+
)
54+
}} = 'monthly'
3655
THEN monthStart
3756
ELSE toStartOfYear(monthStart)
3857
END,
3958
'%Y-%m-%d'
4059
) AS startDate,
4160
formatDateTime(
4261
CASE
43-
WHEN {{ String(granularity, description="Time aggregation: monthly or yearly", required=True) }} = 'monthly'
62+
WHEN
63+
{{
64+
String(
65+
granularity,
66+
description="Time aggregation: monthly or yearly",
67+
required=True,
68+
)
69+
}} = 'monthly'
4470
THEN monthStart + INTERVAL 1 MONTH - INTERVAL 1 DAY
4571
ELSE toStartOfYear(monthStart) + INTERVAL 1 YEAR - INTERVAL 1 DAY
4672
END,
@@ -51,12 +77,14 @@ SQL >
5177
WHERE
5278
toolKey != '__total__'
5379
{% if defined(startDate) %}
54-
AND monthStart >= toDate({{ DateTime(startDate, description="Filter commits after this date", required=False) }})
80+
AND monthStart >= toDate(
81+
{{ DateTime(startDate, description="Filter commits after this date", required=False) }}
82+
)
5583
{% end %}
5684
{% if defined(endDate) %}
57-
AND monthStart < toDate({{ DateTime(endDate, description="Filter commits before this date", required=False) }})
85+
AND monthStart < toDate(
86+
{{ DateTime(endDate, description="Filter commits before this date", required=False) }}
87+
)
5888
{% end %}
5989
GROUP BY toolKey, startDate, endDate
6090
ORDER BY startDate ASC, commitCount DESC
61-
62-
TYPE endpoint

services/libs/tinybird/pipes/ai_code_tracker_commits_copy.pipe

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ TAGS "Report"
77

88
NODE ai_code_tracker_commits_copy_result
99
SQL >
10-
SELECT
11-
a.timestamp,
12-
a.title,
13-
a.body,
14-
a.attributes
10+
SELECT a.timestamp, a.title, a.body, a.attributes
1511
FROM activities_deduplicated_ds a
1612
WHERE a.type = 'authored-commit'
1713

services/libs/tinybird/pipes/ai_code_tracker_copy.pipe

Lines changed: 87 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,71 +10,128 @@ TAGS "Report"
1010
NODE ai_code_tracker_copy_totals
1111
DESCRIPTION >
1212
Total commits per month - simple count, no string scanning
13+
1314
SQL >
14-
SELECT
15-
toStartOfMonth(timestamp) AS monthStart,
16-
'__total__' AS toolKey,
17-
count() AS commitCount
15+
SELECT toStartOfMonth(timestamp) AS monthStart, '__total__' AS toolKey, count() AS commitCount
1816
FROM ai_code_tracker_commits_ds
1917
GROUP BY monthStart
2018

2119
NODE ai_code_tracker_copy_prefilter
2220
DESCRIPTION >
2321
Fast pre-filter: only keep commits containing ANY AI keyword.
2422
multiSearchAnyCaseInsensitive does a single pass instead of dozens of separate checks.
23+
2524
SQL >
26-
SELECT
27-
toStartOfMonth(timestamp) AS monthStart,
28-
title,
29-
body,
30-
attributes
25+
SELECT toStartOfMonth(timestamp) AS monthStart, title, body, attributes
3126
FROM ai_code_tracker_commits_ds
3227
WHERE
33-
multiSearchAnyCaseInsensitive(title, ['copilot', 'chatgpt', 'claude', 'cursor', 'codewhisperer', 'gemini', 'codeium', 'aider', 'devin', 'tabnine', 'ai-generated', 'ai generated']) != 0
34-
OR multiSearchAnyCaseInsensitive(body, ['copilot', 'chatgpt', 'claude', 'cursor', 'codewhisperer', 'gemini', 'codeium', 'aider', 'devin', 'tabnine', 'ai-generated', 'ai generated', 'co-authored-by']) != 0
28+
multiSearchAnyCaseInsensitive(
29+
title,
30+
[
31+
'copilot',
32+
'chatgpt',
33+
'claude',
34+
'cursor',
35+
'codewhisperer',
36+
'gemini',
37+
'codeium',
38+
'aider',
39+
'devin',
40+
'tabnine',
41+
'ai-generated',
42+
'ai generated'
43+
]
44+
)
45+
!= 0
46+
OR multiSearchAnyCaseInsensitive(
47+
body,
48+
[
49+
'copilot',
50+
'chatgpt',
51+
'claude',
52+
'cursor',
53+
'codewhisperer',
54+
'gemini',
55+
'codeium',
56+
'aider',
57+
'devin',
58+
'tabnine',
59+
'ai-generated',
60+
'ai generated',
61+
'co-authored-by'
62+
]
63+
)
64+
!= 0
3565
OR multiSearchAnyCaseInsensitive(attributes, ['copilot', 'ai-generated']) != 0
3666

3767
NODE ai_code_tracker_copy_classify
3868
DESCRIPTION >
3969
Classify pre-filtered commits by AI tool
70+
4071
SQL >
4172
SELECT
4273
monthStart,
4374
multiIf(
44-
positionCaseInsensitive(title, 'github copilot') > 0 OR (positionCaseInsensitive(body, 'co-authored-by') > 0 AND positionCaseInsensitive(body, 'copilot') > 0) OR positionCaseInsensitive(attributes, 'copilot') > 0, 'github-copilot',
45-
positionCaseInsensitive(title, 'cursor') > 0 OR positionCaseInsensitive(body, 'cursor') > 0, 'cursor',
46-
positionCaseInsensitive(title, 'claude') > 0 OR positionCaseInsensitive(body, 'claude') > 0, 'claude',
47-
positionCaseInsensitive(title, 'chatgpt') > 0 OR positionCaseInsensitive(body, 'chatgpt') > 0, 'chatgpt',
48-
positionCaseInsensitive(title, 'codewhisperer') > 0 OR positionCaseInsensitive(body, 'codewhisperer') > 0, 'codewhisperer',
49-
positionCaseInsensitive(title, 'gemini') > 0 OR positionCaseInsensitive(body, 'gemini') > 0, 'gemini',
50-
positionCaseInsensitive(title, 'codeium') > 0 OR positionCaseInsensitive(body, 'codeium') > 0, 'codeium',
51-
positionCaseInsensitive(title, 'copilot') > 0 OR positionCaseInsensitive(body, 'copilot') > 0, 'github-copilot',
52-
positionCaseInsensitive(title, 'aider') > 0 OR positionCaseInsensitive(body, 'aider') > 0, 'aider',
53-
positionCaseInsensitive(title, 'devin') > 0 OR positionCaseInsensitive(body, 'devin') > 0, 'devin',
54-
positionCaseInsensitive(title, 'tabnine') > 0 OR positionCaseInsensitive(body, 'tabnine') > 0, 'tabnine',
55-
positionCaseInsensitive(title, 'ai-generated') > 0 OR positionCaseInsensitive(title, 'ai generated') > 0
56-
OR positionCaseInsensitive(body, 'ai-generated') > 0 OR positionCaseInsensitive(body, 'ai generated') > 0
57-
OR positionCaseInsensitive(attributes, 'ai-generated') > 0
58-
OR (positionCaseInsensitive(body, 'co-authored-by') > 0 AND positionCaseInsensitive(body, 'bot') > 0), 'other',
75+
positionCaseInsensitive(title, 'github copilot') > 0
76+
OR (
77+
positionCaseInsensitive(body, 'co-authored-by') > 0
78+
AND positionCaseInsensitive(body, 'copilot') > 0
79+
)
80+
OR positionCaseInsensitive(attributes, 'copilot') > 0,
81+
'github-copilot',
82+
positionCaseInsensitive(title, 'cursor') > 0 OR positionCaseInsensitive(body, 'cursor') > 0,
83+
'cursor',
84+
positionCaseInsensitive(title, 'claude') > 0 OR positionCaseInsensitive(body, 'claude') > 0,
85+
'claude',
86+
positionCaseInsensitive(title, 'chatgpt') > 0
87+
OR positionCaseInsensitive(body, 'chatgpt') > 0,
88+
'chatgpt',
89+
positionCaseInsensitive(title, 'codewhisperer') > 0
90+
OR positionCaseInsensitive(body, 'codewhisperer') > 0,
91+
'codewhisperer',
92+
positionCaseInsensitive(title, 'gemini') > 0 OR positionCaseInsensitive(body, 'gemini') > 0,
93+
'gemini',
94+
positionCaseInsensitive(title, 'codeium') > 0
95+
OR positionCaseInsensitive(body, 'codeium') > 0,
96+
'codeium',
97+
positionCaseInsensitive(title, 'copilot') > 0
98+
OR positionCaseInsensitive(body, 'copilot') > 0,
99+
'github-copilot',
100+
positionCaseInsensitive(title, 'aider') > 0 OR positionCaseInsensitive(body, 'aider') > 0,
101+
'aider',
102+
positionCaseInsensitive(title, 'devin') > 0 OR positionCaseInsensitive(body, 'devin') > 0,
103+
'devin',
104+
positionCaseInsensitive(title, 'tabnine') > 0
105+
OR positionCaseInsensitive(body, 'tabnine') > 0,
106+
'tabnine',
107+
positionCaseInsensitive(title, 'ai-generated') > 0
108+
OR positionCaseInsensitive(title, 'ai generated') > 0
109+
OR positionCaseInsensitive(body, 'ai-generated') > 0
110+
OR positionCaseInsensitive(body, 'ai generated') > 0
111+
OR positionCaseInsensitive(attributes, 'ai-generated') > 0
112+
OR (
113+
positionCaseInsensitive(body, 'co-authored-by') > 0
114+
AND positionCaseInsensitive(body, 'bot') > 0
115+
),
116+
'other',
59117
'__none__'
60118
) AS toolKey
61119
FROM ai_code_tracker_copy_prefilter
62120

63121
NODE ai_code_tracker_copy_by_tool
64122
DESCRIPTION >
65123
Aggregate AI commits by month and tool
124+
66125
SQL >
67-
SELECT
68-
monthStart,
69-
toolKey,
70-
count() AS commitCount
126+
SELECT monthStart, toolKey, count() AS commitCount
71127
FROM ai_code_tracker_copy_classify
72128
WHERE toolKey != '__none__'
73129
GROUP BY monthStart, toolKey
74130

75131
NODE ai_code_tracker_copy_result
76132
DESCRIPTION >
77133
Union AI tool counts and total counts
134+
78135
SQL >
79136
SELECT monthStart, toolKey, commitCount
80137
FROM ai_code_tracker_copy_by_tool

services/libs/tinybird/pipes/ai_code_tracker_total_commits.pipe

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ TAGS "Report"
1212
NODE ai_code_tracker_total_commits_result
1313
DESCRIPTION >
1414
Aggregate pre-computed total commit counts by time period
15+
1516
SQL >
1617
%
1718
SELECT
1819
formatDateTime(
1920
CASE
20-
WHEN {{ String(granularity, description="Time aggregation: monthly or yearly", required=True) }} = 'monthly'
21+
WHEN
22+
{{
23+
String(
24+
granularity,
25+
description="Time aggregation: monthly or yearly",
26+
required=True,
27+
)
28+
}} = 'monthly'
2129
THEN monthStart
2230
ELSE toStartOfYear(monthStart)
2331
END,
@@ -28,12 +36,14 @@ SQL >
2836
WHERE
2937
toolKey = '__total__'
3038
{% if defined(startDate) %}
31-
AND monthStart >= toDate({{ DateTime(startDate, description="Filter commits after this date", required=False) }})
39+
AND monthStart >= toDate(
40+
{{ DateTime(startDate, description="Filter commits after this date", required=False) }}
41+
)
3242
{% end %}
3343
{% if defined(endDate) %}
34-
AND monthStart < toDate({{ DateTime(endDate, description="Filter commits before this date", required=False) }})
44+
AND monthStart < toDate(
45+
{{ DateTime(endDate, description="Filter commits before this date", required=False) }}
46+
)
3547
{% end %}
3648
GROUP BY startDate
3749
ORDER BY startDate ASC
38-
39-
TYPE endpoint

0 commit comments

Comments
 (0)