Skip to content

Commit 78a8257

Browse files
committed
format
1 parent 397bf98 commit 78a8257

File tree

6 files changed

+170
-170
lines changed

6 files changed

+170
-170
lines changed

alter_default_value_in_column/pipes/kpis.pipe

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,61 @@ TOKEN "dashboard" READ
99
NODE timeseries
1010
DESCRIPTION >
1111
Generate a timeseries for the specified time range, so we call fill empty data points.
12-
Filters "future" data points.
12+
Filters "future" data points.
1313

1414
SQL >
1515

1616
%
17-
{% set _single_day = defined(date_from) and day_diff(date_from, date_to) == 0 %}
18-
with
19-
{% if defined(date_from) %}
20-
toStartOfDay(
21-
toDate(
22-
{{
23-
Date(
24-
date_from,
25-
description="Starting day for filtering a date range",
26-
required=False,
27-
)
28-
}}
29-
)
30-
) as start,
31-
{% else %} toStartOfDay(timestampAdd(today(), interval -7 day)) as start,
32-
{% end %}
33-
{% if defined(date_to) %}
34-
toStartOfDay(
35-
toDate(
36-
{{
37-
Date(
38-
date_to,
39-
description="Finishing day for filtering a date range",
40-
required=False,
17+
{% set _single_day = defined(date_from) and day_diff(date_from, date_to) == 0 %}
18+
with
19+
{% if defined(date_from) %}
20+
toStartOfDay(
21+
toDate(
22+
{{
23+
Date(
24+
date_from,
25+
description="Starting day for filtering a date range",
26+
required=False,
27+
)
28+
}}
29+
)
30+
) as start,
31+
{% else %} toStartOfDay(timestampAdd(today(), interval -7 day)) as start,
32+
{% end %}
33+
{% if defined(date_to) %}
34+
toStartOfDay(
35+
toDate(
36+
{{
37+
Date(
38+
date_to,
39+
description="Finishing day for filtering a date range",
40+
required=False,
41+
)
42+
}}
43+
)
44+
) as end
45+
{% else %} toStartOfDay(today()) as end
46+
{% end %}
47+
{% if _single_day %}
48+
select
49+
arrayJoin(
50+
arrayMap(
51+
x -> toDateTime(x),
52+
range(
53+
toUInt32(toDateTime(start)), toUInt32(timestampAdd(end, interval 1 day)), 3600
4154
)
42-
}}
43-
)
44-
) as end
45-
{% else %} toStartOfDay(today()) as end
46-
{% end %}
47-
{% if _single_day %}
48-
select
49-
arrayJoin(
50-
arrayMap(
51-
x -> toDateTime(x),
52-
range(
53-
toUInt32(toDateTime(start)), toUInt32(timestampAdd(end, interval 1 day)), 3600
5455
)
55-
)
56-
) as date
57-
{% else %}
58-
select
59-
arrayJoin(
60-
arrayMap(
61-
x -> toDate(x),
62-
range(toUInt32(start), toUInt32(timestampAdd(end, interval 1 day)), 24 * 3600)
63-
)
64-
) as date
65-
{% end %}
66-
where date <= now()
56+
) as date
57+
{% else %}
58+
select
59+
arrayJoin(
60+
arrayMap(
61+
x -> toDate(x),
62+
range(toUInt32(start), toUInt32(timestampAdd(end, interval 1 day)), 24 * 3600)
63+
)
64+
) as date
65+
{% end %}
66+
where date <= now()
6767

6868

6969

@@ -74,37 +74,37 @@ DESCRIPTION >
7474
SQL >
7575

7676
%
77-
{% if defined(date_from) and day_diff(date_from, date_to) == 0 %}
78-
select
79-
toStartOfHour(timestamp) as date,
80-
session_id,
81-
uniq(session_id) as visits,
82-
count() as pageviews,
83-
case when min(timestamp) = max(timestamp) then 1 else 0 end as is_bounce,
84-
max(timestamp) as latest_hit_aux,
85-
min(timestamp) as first_hit_aux
86-
from analytics_hits
87-
where toDate(timestamp) = {{ Date(date_from) }}
88-
group by toStartOfHour(timestamp), session_id
89-
{% else %}
90-
select
91-
date,
92-
session_id,
93-
uniq(session_id) as visits,
94-
countMerge(hits) as pageviews,
95-
case when min(first_hit) = max(latest_hit) then 1 else 0 end as is_bounce,
96-
max(latest_hit) as latest_hit_aux,
97-
min(first_hit) as first_hit_aux
98-
from analytics_sessions_mv
99-
where
100-
{% if defined(date_from) %} date >= {{ Date(date_from) }}
101-
{% else %} date >= timestampAdd(today(), interval -7 day)
102-
{% end %}
103-
{% if defined(date_to) %} and date <= {{ Date(date_to) }}
104-
{% else %} and date <= today()
105-
{% end %}
106-
group by date, session_id
107-
{% end %}
77+
{% if defined(date_from) and day_diff(date_from, date_to) == 0 %}
78+
select
79+
toStartOfHour(timestamp) as date,
80+
session_id,
81+
uniq(session_id) as visits,
82+
count() as pageviews,
83+
case when min(timestamp) = max(timestamp) then 1 else 0 end as is_bounce,
84+
max(timestamp) as latest_hit_aux,
85+
min(timestamp) as first_hit_aux
86+
from analytics_hits
87+
where toDate(timestamp) = {{ Date(date_from) }}
88+
group by toStartOfHour(timestamp), session_id
89+
{% else %}
90+
select
91+
date,
92+
session_id,
93+
uniq(session_id) as visits,
94+
countMerge(hits) as pageviews,
95+
case when min(first_hit) = max(latest_hit) then 1 else 0 end as is_bounce,
96+
max(latest_hit) as latest_hit_aux,
97+
min(first_hit) as first_hit_aux
98+
from analytics_sessions_mv
99+
where
100+
{% if defined(date_from) %} date >= {{ Date(date_from) }}
101+
{% else %} date >= timestampAdd(today(), interval -7 day)
102+
{% end %}
103+
{% if defined(date_to) %} and date <= {{ Date(date_to) }}
104+
{% else %} and date <= today()
105+
{% end %}
106+
group by date, session_id
107+
{% end %}
108108

109109

110110

alter_default_value_in_column/pipes/top_browsers.pipe

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ DESCRIPTION >
1313
SQL >
1414

1515
%
16-
select browser, uniqMerge(visits) as visits, countMerge(hits) as hits
17-
from analytics_sources_mv
18-
where
19-
{% if defined(date_from) %}
20-
date
21-
>=
22-
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23-
{% else %} date >= timestampAdd(today(), interval -7 day)
24-
{% end %}
25-
{% if defined(date_to) %}
26-
and date
27-
<=
28-
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29-
{% else %} and date <= today()
30-
{% end %}
31-
group by browser
32-
order by visits desc
33-
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
16+
select browser, uniqMerge(visits) as visits, countMerge(hits) as hits
17+
from analytics_sources_mv
18+
where
19+
{% if defined(date_from) %}
20+
date
21+
>=
22+
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23+
{% else %} date >= timestampAdd(today(), interval -7 day)
24+
{% end %}
25+
{% if defined(date_to) %}
26+
and date
27+
<=
28+
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29+
{% else %} and date <= today()
30+
{% end %}
31+
group by browser
32+
order by visits desc
33+
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
3434

3535

alter_default_value_in_column/pipes/top_devices.pipe

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ DESCRIPTION >
1313
SQL >
1414

1515
%
16-
select device, uniqMerge(visits) as visits, countMerge(hits) as hits
17-
from analytics_sources_mv
18-
where
19-
{% if defined(date_from) %}
20-
date
21-
>=
22-
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23-
{% else %} date >= timestampAdd(today(), interval -7 day)
24-
{% end %}
25-
{% if defined(date_to) %}
26-
and date
27-
<=
28-
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29-
{% else %} and date <= today()
30-
{% end %}
31-
group by device
32-
order by visits desc
33-
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
16+
select device, uniqMerge(visits) as visits, countMerge(hits) as hits
17+
from analytics_sources_mv
18+
where
19+
{% if defined(date_from) %}
20+
date
21+
>=
22+
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23+
{% else %} date >= timestampAdd(today(), interval -7 day)
24+
{% end %}
25+
{% if defined(date_to) %}
26+
and date
27+
<=
28+
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29+
{% else %} and date <= today()
30+
{% end %}
31+
group by device
32+
order by visits desc
33+
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
3434

3535

alter_default_value_in_column/pipes/top_locations.pipe

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ DESCRIPTION >
1313
SQL >
1414

1515
%
16-
select location, uniqMerge(visits) as visits, countMerge(hits) as hits
17-
from analytics_pages_mv
18-
where
19-
{% if defined(date_from) %}
20-
date
21-
>=
22-
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23-
{% else %} date >= timestampAdd(today(), interval -7 day)
24-
{% end %}
25-
{% if defined(date_to) %}
26-
and date
27-
<=
28-
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29-
{% else %} and date <= today()
30-
{% end %}
31-
group by location
32-
order by visits desc
33-
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
16+
select location, uniqMerge(visits) as visits, countMerge(hits) as hits
17+
from analytics_pages_mv
18+
where
19+
{% if defined(date_from) %}
20+
date
21+
>=
22+
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23+
{% else %} date >= timestampAdd(today(), interval -7 day)
24+
{% end %}
25+
{% if defined(date_to) %}
26+
and date
27+
<=
28+
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29+
{% else %} and date <= today()
30+
{% end %}
31+
group by location
32+
order by visits desc
33+
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
3434

3535

alter_default_value_in_column/pipes/top_pages.pipe

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ DESCRIPTION >
1313
SQL >
1414

1515
%
16-
select pathname, uniqMerge(visits) as visits, countMerge(hits) as hits
17-
from analytics_pages_mv
18-
where
19-
{% if defined(date_from) %}
20-
date
21-
>=
22-
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23-
{% else %} date >= timestampAdd(today(), interval -7 day)
24-
{% end %}
25-
{% if defined(date_to) %}
26-
and date
27-
<=
28-
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29-
{% else %} and date <= today()
30-
{% end %}
31-
group by pathname
32-
order by visits desc
33-
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
16+
select pathname, uniqMerge(visits) as visits, countMerge(hits) as hits
17+
from analytics_pages_mv
18+
where
19+
{% if defined(date_from) %}
20+
date
21+
>=
22+
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23+
{% else %} date >= timestampAdd(today(), interval -7 day)
24+
{% end %}
25+
{% if defined(date_to) %}
26+
and date
27+
<=
28+
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29+
{% else %} and date <= today()
30+
{% end %}
31+
group by pathname
32+
order by visits desc
33+
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
3434

3535

alter_default_value_in_column/pipes/top_sources.pipe

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ DESCRIPTION >
1313
SQL >
1414

1515
%
16-
select domainWithoutWWW(referrer) as referrer, uniqMerge(visits) as visits, countMerge(hits) as hits
17-
from analytics_sources_mv
18-
where
19-
{% if defined(date_from) %}
20-
date
21-
>=
22-
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23-
{% else %} date >= timestampAdd(today(), interval -7 day)
24-
{% end %}
25-
{% if defined(date_to) %}
26-
and date
27-
<=
28-
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29-
{% else %} and date <= today()
30-
{% end %}
31-
group by referrer
32-
order by visits desc
33-
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
16+
select domainWithoutWWW(referrer) as referrer, uniqMerge(visits) as visits, countMerge(hits) as hits
17+
from analytics_sources_mv
18+
where
19+
{% if defined(date_from) %}
20+
date
21+
>=
22+
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
23+
{% else %} date >= timestampAdd(today(), interval -7 day)
24+
{% end %}
25+
{% if defined(date_to) %}
26+
and date
27+
<=
28+
{{ Date(date_to, description="Finishing day for filtering a date range", required=False) }}
29+
{% else %} and date <= today()
30+
{% end %}
31+
group by referrer
32+
order by visits desc
33+
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
3434

3535

0 commit comments

Comments
 (0)