Skip to content

Commit e7688e1

Browse files
committed
Merge branch 'main' into dynamic-bounty-start-date
2 parents 94ca42d + ef8bac9 commit e7688e1

33 files changed

Lines changed: 664 additions & 631 deletions

packages/tinybird/datasources/dub_api_logs.datasource

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
TOKEN "dub_tinybird_token" APPEND
22

3+
34
SCHEMA >
45
`id` String `json:$.id`,
56
`timestamp` DateTime64(3) `json:$.timestamp`,
@@ -11,7 +12,7 @@ SCHEMA >
1112
`duration` UInt32 `json:$.duration`,
1213
`user_agent` String `json:$.user_agent`,
1314
`request_body` String `json:$.request_body`,
14-
`query_params` String `json:$.query_params`,
15+
`query_params` String `json:$.query_params` DEFAULT '',
1516
`response_body` String `json:$.response_body`,
1617
`token_id` String `json:$.token_id`,
1718
`user_id` String `json:$.user_id`,

packages/tinybird/datasources/dub_conversion_events_log.datasource

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
TOKEN "dub_tinybird_token" APPEND
22

3+
DESCRIPTION >
4+
DEPRECATED: We're using dub_api_logs now. This is kept for posterity
35

46
SCHEMA >
57
`timestamp` DateTime64(3) `json:$.timestamp` DEFAULT now(),

packages/tinybird/datasources/dub_links_metadata_latest.datasource

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ SCHEMA >
1010
`program_id` LowCardinality(String),
1111
`partner_id` String,
1212
`partner_group_id` String,
13+
`partner_tag_ids` Array(String),
1314
`folder_id` String,
1415
`tag_ids` Array(String),
15-
`partner_tag_ids` Array(String) DEFAULT [],
1616
`tenant_id` String,
1717
`created_at` DateTime64(3),
1818
`deleted` UInt8

packages/tinybird/pipes/all_stats.pipe

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ TAGS "Dub Misc Endpoints"
33
NODE endpoint
44
SQL >
55

6-
SELECT
7-
(SELECT COUNT(timestamp) FROM dub_click_events_mv) AS clicks,
6+
SELECT
7+
(
8+
SELECT
9+
(SELECT count() FROM dub_click_events_mv)
10+
+ (SELECT count() FROM dub_lead_events_mv)
11+
+ (SELECT count() FROM dub_sale_events_mv)
12+
) AS events,
813
(SELECT COUNT(timestamp) + 42036155 FROM dub_links_metadata) AS links,
914
(SELECT SUM(amount) FROM dub_sale_events_mv) AS sales
1015

11-
16+
TYPE ENDPOINT

packages/tinybird/pipes/coordinates_all.pipe

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,94 @@ TAGS "Dub Misc Endpoints"
33
NODE coordinates_clicks_data
44
SQL >
55

6-
%
7-
SELECT
8-
'click' AS event,
9-
timestamp,
10-
country,
11-
city,
12-
latitude,
13-
longitude,
14-
device
15-
FROM dub_click_events_mv
16-
WHERE
17-
timestamp > now() - INTERVAL 5 MINUTE
18-
AND country != 'Unknown' AND city != 'Unknown' AND city != 'Ashburn'
19-
ORDER BY timestamp DESC
20-
LIMIT 100
6+
%
7+
SELECT
8+
'click' AS event,
9+
timestamp,
10+
country,
11+
city,
12+
latitude,
13+
longitude,
14+
device
15+
FROM dub_click_events_mv
16+
WHERE
17+
timestamp > now() - INTERVAL 5 MINUTE
18+
AND country != 'Unknown' AND city != 'Unknown' AND city != 'Ashburn'
19+
ORDER BY timestamp DESC
20+
LIMIT 100
2121

2222

2323

2424
NODE coordinates_leads_data
2525
SQL >
2626

27-
%
28-
SELECT
29-
'lead' AS event,
30-
timestamp,
31-
country,
32-
city,
33-
latitude,
34-
longitude,
35-
device
36-
FROM dub_lead_events_mv
37-
WHERE
38-
timestamp > now() - INTERVAL 12 HOUR
39-
AND country != 'Unknown'
40-
AND city != 'Unknown'
41-
AND city != 'Ashburn'
42-
ORDER BY timestamp DESC
43-
LIMIT 100
27+
%
28+
SELECT
29+
'lead' AS event,
30+
timestamp,
31+
country,
32+
city,
33+
latitude,
34+
longitude,
35+
device
36+
FROM dub_lead_events_mv
37+
WHERE
38+
timestamp > now() - INTERVAL 12 HOUR
39+
AND country != 'Unknown'
40+
AND city != 'Unknown'
41+
AND city != 'Ashburn'
42+
ORDER BY timestamp DESC
43+
LIMIT 100
4444

4545

4646

4747
NODE coordinates_sales_data
4848
SQL >
4949

50-
%
51-
SELECT
52-
'sale' AS event,
53-
timestamp,
54-
country,
55-
city,
56-
latitude,
57-
longitude,
58-
device,
59-
amount,
60-
round(
61-
amount * arrayElement([0.3, 0.4, 0.5], 1 + (toUnixTimestamp(timestamp) % 3))
62-
) as commission
63-
FROM dub_sale_events_mv
64-
WHERE
65-
timestamp > now() - INTERVAL 12 HOUR
66-
AND country != 'Unknown'
67-
AND city != 'Unknown'
68-
AND city != 'Ashburn'
69-
ORDER BY timestamp DESC
70-
LIMIT 100
50+
%
51+
SELECT
52+
'sale' AS event,
53+
timestamp,
54+
country,
55+
city,
56+
latitude,
57+
longitude,
58+
device,
59+
amount,
60+
round(
61+
amount * arrayElement([0.3, 0.4, 0.5], 1 + (toUnixTimestamp(timestamp) % 3))
62+
) as commission
63+
FROM dub_sale_events_mv
64+
WHERE
65+
timestamp > now() - INTERVAL 12 HOUR
66+
AND country != 'Unknown'
67+
AND city != 'Unknown'
68+
AND city != 'Ashburn'
69+
ORDER BY timestamp DESC
70+
LIMIT 100
7171

7272

7373

7474
NODE endpoint
7575
SQL >
7676

77-
%
78-
SELECT *
79-
FROM
80-
(
81-
SELECT *, NULL AS amount, NULL AS commission
82-
FROM coordinates_leads_data
83-
UNION ALL
84-
SELECT
85-
*,
86-
NULL AS amount,
87-
NULL AS commission
88-
FROM coordinates_clicks_data
89-
UNION ALL
90-
SELECT *
91-
FROM coordinates_sales_data
92-
)
93-
ORDER BY
94-
timestamp DESC
95-
96-
77+
%
78+
SELECT *
79+
FROM
80+
(
81+
SELECT *, NULL AS amount, NULL AS commission
82+
FROM coordinates_leads_data
83+
UNION ALL
84+
SELECT
85+
*,
86+
NULL AS amount,
87+
NULL AS commission
88+
FROM coordinates_clicks_data
89+
UNION ALL
90+
SELECT *
91+
FROM coordinates_sales_data
92+
)
93+
ORDER BY
94+
timestamp DESC
95+
96+
TYPE ENDPOINT

packages/tinybird/pipes/coordinates_sales.pipe

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ TAGS "Dub Misc Endpoints"
33
NODE endpoint
44
SQL >
55

6-
%
7-
SELECT
8-
timestamp,
9-
amount,
10-
round(
11-
amount * arrayElement([0.3, 0.4, 0.5], 1 + (toUnixTimestamp(timestamp) % 3))
12-
) as commission,
13-
country,
14-
city,
15-
latitude,
16-
longitude
17-
FROM dub_sale_events_mv
18-
WHERE
19-
timestamp > now() - INTERVAL 12 HOUR
20-
AND country != 'Unknown'
21-
AND city != 'Unknown'
22-
AND city != 'Ashburn'
23-
ORDER BY timestamp DESC
24-
LIMIT 500
25-
6+
%
7+
SELECT
8+
timestamp,
9+
amount,
10+
round(
11+
amount * arrayElement([0.3, 0.4, 0.5], 1 + (toUnixTimestamp(timestamp) % 3))
12+
) as commission,
13+
country,
14+
city,
15+
latitude,
16+
longitude
17+
FROM dub_sale_events_mv
18+
WHERE
19+
timestamp > now() - INTERVAL 12 HOUR
20+
AND country != 'Unknown'
21+
AND city != 'Unknown'
22+
AND city != 'Ashburn'
23+
ORDER BY timestamp DESC
24+
LIMIT 500
2625

26+
TYPE ENDPOINT

packages/tinybird/pipes/dub_links_metadata_pipe.pipe

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SQL >
1919
toLowCardinality(program_id) program_id,
2020
partner_id,
2121
partner_group_id,
22+
partner_tag_ids,
2223
folder_id,
2324
tag_ids,
2425
tenant_id,

packages/tinybird/pipes/get_api_log_by_id.pipe

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
NODE endpoint
22
SQL >
3-
%
3+
4+
%
45
SELECT
56
id,
67
timestamp,
@@ -21,3 +22,5 @@ SQL >
2122
id = {{ String(id) }}
2223
AND workspace_id = {{ String(workspaceId) }}
2324
LIMIT 1
25+
26+
TYPE ENDPOINT

packages/tinybird/pipes/get_api_logs.pipe

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
NODE endpoint
22
SQL >
3-
%
3+
4+
%
45
SELECT
56
id,
67
timestamp,
@@ -32,3 +33,5 @@ SQL >
3233
ORDER BY timestamp DESC
3334
LIMIT {{ Int32(limit, 100) }}
3435
OFFSET {{ Int32(offset, 0) }}
36+
37+
TYPE ENDPOINT

packages/tinybird/pipes/get_api_logs_count.pipe

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
NODE count
22
SQL >
3-
%
3+
4+
%
45
SELECT
56
count() as count
67
FROM dub_api_logs
@@ -17,9 +18,12 @@ SQL >
1718
{% if defined(requestId) %} AND id = {{ String(requestId) }} {% end %}
1819
{% if defined(requestType) %} AND request_type = {{ String(requestType) }} {% end %}
1920

21+
22+
2023
NODE count_by_route_pattern
2124
SQL >
22-
%
25+
26+
%
2327
SELECT
2428
route_pattern as routePattern,
2529
count() as count
@@ -41,9 +45,12 @@ SQL >
4145
ORDER BY count DESC
4246
LIMIT 100
4347

48+
49+
4450
NODE count_by_status_code
4551
SQL >
46-
%
52+
53+
%
4754
SELECT
4855
status_code as statusCode,
4956
count() as count
@@ -63,9 +70,12 @@ SQL >
6370
GROUP BY status_code
6471
ORDER BY count DESC
6572

73+
74+
6675
NODE count_by_method
6776
SQL >
68-
%
77+
78+
%
6979
SELECT
7080
method,
7181
count() as count
@@ -85,13 +95,18 @@ SQL >
8595
GROUP BY method
8696
ORDER BY count DESC
8797

98+
99+
88100
NODE endpoint
89101
SQL >
90-
%
102+
103+
%
91104
SELECT *
92105
FROM
93106
{% if defined(groupBy) and groupBy == 'routePattern' %} count_by_route_pattern
94107
{% elif defined(groupBy) and groupBy == 'statusCode' %} count_by_status_code
95108
{% elif defined(groupBy) and groupBy == 'method' %} count_by_method
96109
{% else %} count
97110
{% end %}
111+
112+
TYPE ENDPOINT

0 commit comments

Comments
 (0)