Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new endpoint #304

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions iterating_api_endpoint/pipes/top_browsers_1.pipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
DESCRIPTION >
Top Browsers ordered by most visits.
Accepts `date_from` and `date_to` date filter. Defaults to last 7 days.
Also `skip` and `limit` parameters for pagination.


TOKEN "dashboard" READ

NODE endpoint
DESCRIPTION >
Group by browser and calcualte hits and visits

SQL >

%
select
browser,
device,
uniqMerge(visits) as visits,
countMerge(hits) as hits
from
analytics_sources_mv
where
{% if defined(date_from) %}
date >= {{Date(date_from, description="Starting day for filtering a date range", required=False)}}
{% else %}
date >= timestampAdd(today(), interval -7 day)
{% end %}
{% if defined(date_to) %}
and date <= {{Date(date_to, description="Finishing day for filtering a date range", required=False)}}
{% else %}
and date <= today()
{% end %}
group by
browser, device
order by
visits desc
limit {{Int32(skip, 0)}},{{Int32(limit, 50)}}


1 change: 1 addition & 0 deletions iterating_api_endpoint/tests/top_browser_1_default.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tb pipe data top_browsers_1 --date_from 2024-01-11 --date_to 2024-01-12 --format CSV
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"browser","device","visits","hits"
"chrome","desktop",1,2
"firefox","desktop",1,1
"chrome","mobile-android",1,1