Skip to content

Commit

Permalink
update tb pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
devkiran committed Jan 31, 2025
1 parent 3519dbe commit edd4cda
Show file tree
Hide file tree
Showing 17 changed files with 584 additions and 200 deletions.
39 changes: 25 additions & 14 deletions packages/tinybird/pipes/v2_browsers.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ DESCRIPTION >

TOKEN "v2_browsers_endpoint_read_1118" READ

TAGS "Dub Endpoints"

NODE workspace_links
SQL >

%
SELECT link_id
from dub_links_metadata_latest FINAL
WHERE
workspace_id
= {{
String(
workspaceId,
'ws_cl7pj5kq4006835rbjlt2ofka',
description="The ID of the workspace",
required=True,
)
}}
AND deleted == 0
deleted == 0
{% if defined(workspaceId) %} AND workspace_id = {{ workspaceId }} {% end %}
{% if defined(programId) %} AND program_id = {{ programId }} {% end %}
{% if defined(partnerId) %} AND partner_id = {{ partnerId }} {% end %}
{% if defined(tenantId) %} AND tenant_id = {{ tenantId }} {% end %}
{% if defined(folderId) %} AND folder_id = {{ folderId }} {% end %}
{% if defined(domain) %} AND domain IN {{ Array(domain, 'String') }} {% end %}
{% if defined(tagIds) %} AND arrayIntersect(tag_ids, {{ Array(tagIds, 'String') }}) != [] {% end %}
{% if defined(root) %}
Expand All @@ -37,7 +34,7 @@ SQL >
SELECT browser, COUNT(browser) as clicks
FROM
dub_click_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -53,6 +50,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
Expand All @@ -68,7 +70,7 @@ SQL >
SELECT browser, COUNT(browser) as leads
FROM
dub_lead_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -84,6 +86,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
Expand All @@ -105,7 +112,7 @@ SQL >
SELECT browser, COUNT(*) as sales, sum(amount) as amount
FROM
dub_sale_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -121,6 +128,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
Expand Down Expand Up @@ -153,4 +165,3 @@ SQL >
{% else %} browsers_composite
{% end %}


38 changes: 25 additions & 13 deletions packages/tinybird/pipes/v2_cities.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ DESCRIPTION >

TOKEN "v2_cities_endpoint_read_6984" READ

TAGS "Dub Endpoints"

NODE workspace_links
SQL >

%
SELECT link_id
from dub_links_metadata_latest FINAL
WHERE
workspace_id
= {{
String(
workspaceId,
'ws_cl7pj5kq4006835rbjlt2ofka',
description="The ID of the workspace",
required=True,
)
}}
AND deleted == 0
deleted == 0
{% if defined(workspaceId) %} AND workspace_id = {{ workspaceId }} {% end %}
{% if defined(programId) %} AND program_id = {{ programId }} {% end %}
{% if defined(partnerId) %} AND partner_id = {{ partnerId }} {% end %}
{% if defined(tenantId) %} AND tenant_id = {{ tenantId }} {% end %}
{% if defined(folderId) %} AND folder_id = {{ folderId }} {% end %}
{% if defined(domain) %} AND domain IN {{ Array(domain, 'String') }} {% end %}
{% if defined(tagIds) %} AND arrayIntersect(tag_ids, {{ Array(tagIds, 'String') }}) != [] {% end %}
{% if defined(root) %}
Expand All @@ -37,7 +34,7 @@ SQL >
SELECT city, country, COUNT(city) as clicks
FROM
dub_click_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -53,6 +50,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
Expand All @@ -68,7 +70,7 @@ SQL >
SELECT city, country, COUNT(city) as leads
FROM
dub_lead_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -84,6 +86,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
Expand All @@ -106,7 +113,7 @@ SQL >
SELECT city, country, COUNT(city) as sales, sum(amount) as amount
FROM
dub_sale_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -122,6 +129,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
Expand Down
38 changes: 25 additions & 13 deletions packages/tinybird/pipes/v2_continents.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ DESCRIPTION >

TOKEN "v2_continents_endpoint_read_0662" READ

TAGS "Dub Endpoints"

NODE workspace_links
SQL >

%
SELECT link_id
from dub_links_metadata_latest FINAL
WHERE
workspace_id
= {{
String(
workspaceId,
'ws_cl7pj5kq4006835rbjlt2ofka',
description="The ID of the workspace",
required=True,
)
}}
AND deleted == 0
deleted == 0
{% if defined(workspaceId) %} AND workspace_id = {{ workspaceId }} {% end %}
{% if defined(programId) %} AND program_id = {{ programId }} {% end %}
{% if defined(partnerId) %} AND partner_id = {{ partnerId }} {% end %}
{% if defined(tenantId) %} AND tenant_id = {{ tenantId }} {% end %}
{% if defined(folderId) %} AND folder_id = {{ folderId }} {% end %}
{% if defined(domain) %} AND domain IN {{ Array(domain, 'String') }} {% end %}
{% if defined(tagIds) %} AND arrayIntersect(tag_ids, {{ Array(tagIds, 'String') }}) != [] {% end %}
{% if defined(root) %}
Expand All @@ -37,7 +34,7 @@ SQL >
SELECT continent, COUNT(continent) as clicks
FROM
dub_click_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -62,6 +59,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
Expand All @@ -77,7 +79,7 @@ SQL >
SELECT continent, COUNT(continent) as leads
FROM
dub_lead_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -102,6 +104,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
Expand All @@ -123,7 +130,7 @@ SQL >
SELECT continent, COUNT(continent) as sales, sum(amount) as amount
FROM
dub_sale_events_mv
{% if not defined(linkId) and defined(workspaceId) %}
{% if not defined(linkId) and (defined(workspaceId) or defined(partnerId) or defined(programId)) %}
PREWHERE link_id in (SELECT link_id from workspace_links)
{% end %}
WHERE
Expand All @@ -148,6 +155,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
{% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
{% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
{% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
{% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
{% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
Expand Down
Loading

0 comments on commit edd4cda

Please sign in to comment.