mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
7ebb208549
ref https://linear.app/tryghost/issue/ANAL-96/data-discrepancy-between-charts-when-filtering - The top browser and device endpoints were pulling from the sources MV, that is filtered to not have same-source traffic
43 lines
2.0 KiB
Plaintext
43 lines
2.0 KiB
Plaintext
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
|
|
TOKEN "stats page" READ
|
|
|
|
NODE endpoint
|
|
DESCRIPTION >
|
|
Group by browser and calculate views and visits
|
|
|
|
SQL >
|
|
%
|
|
select browser, uniq(session_id) as visits, countMerge(pageviews) as pageviews
|
|
from analytics_sessions_mv
|
|
where
|
|
site_uuid = {{String(site_uuid, 'mock_site_uuid', description="Tenant ID", required=True)}}
|
|
|
|
{% if defined(date_from) %}
|
|
and date
|
|
>=
|
|
{{ Date(date_from, description="Starting day for filtering a date range", required=False) }}
|
|
{% else %}
|
|
and 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 %}
|
|
|
|
{% if defined(member_status) %} and member_status IN {{ Array(member_status, "'undefined', 'free', 'paid'", description="Member status to filter on", required=False) }} {% end %}
|
|
{% if defined(device) %} and device = {{ String(device, description="Device to filter on", required=False) }} {% end %}
|
|
{% if defined(browser) %} and browser = {{ String(browser, description="Browser to filter on", required=False) }} {% end %}
|
|
{% if defined(source) %} and source = {{ String(source, description="Source to filter on", required=False) }} {% end %}
|
|
{% if defined(location) %} and location = {{ String(location, description="Location to filter on", required=False) }} {% end %}
|
|
{% if defined(pathname) %} and pathname = {{ String(pathname, description="Pathname to filter on", required=False) }} {% end %}
|
|
group by browser
|
|
order by visits desc
|
|
limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }}
|