mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Fixed tinybird charts when viewing < 1 day date ranges (#21912)
- This case works significantly differently to the normal KPIs and was
untested, so we didn't spot that we broke it.
- This adds a test, and brings in the fix by @FGonzalezLopez from
41029a4476
- This fixes the charts in so much as they no longer error
- However, the test result is indicating another bug as we're getting a row per second, instead of one row per hour which is what we actually expect to happen
---------
Co-authored-by: Paco Gonzalez <paco@tinybird.co>
This commit is contained in:
parent
509dd6229f
commit
69474bb7db
3 changed files with 7267 additions and 1 deletions
|
@ -65,6 +65,69 @@ SQL >
|
|||
) as date
|
||||
{% end %}
|
||||
|
||||
NODE parsed_hits
|
||||
DESCRIPTION >
|
||||
Parse raw page_hit events
|
||||
|
||||
SQL >
|
||||
SELECT
|
||||
timestamp,
|
||||
action,
|
||||
version,
|
||||
coalesce(session_id, '0') as session_id,
|
||||
JSONExtractString(payload, 'locale') as locale,
|
||||
JSONExtractString(payload, 'location') as location,
|
||||
JSONExtractString(payload, 'referrer') as referrer,
|
||||
JSONExtractString(payload, 'pathname') as pathname,
|
||||
JSONExtractString(payload, 'href') as href,
|
||||
JSONExtractString(payload, 'site_uuid') as site_uuid,
|
||||
JSONExtractString(payload, 'member_uuid') as member_uuid,
|
||||
JSONExtractString(payload, 'member_status') as member_status,
|
||||
JSONExtractString(payload, 'post_uuid') as post_uuid,
|
||||
JSONExtractString(payload, 'post_type') as post_type,
|
||||
lower(JSONExtractString(payload, 'user-agent')) as user_agent
|
||||
FROM analytics_events
|
||||
where action = 'page_hit'
|
||||
|
||||
NODE analytics_hits_data
|
||||
SQL >
|
||||
SELECT
|
||||
site_uuid,
|
||||
timestamp,
|
||||
action,
|
||||
version,
|
||||
session_id,
|
||||
member_uuid,
|
||||
member_status,
|
||||
post_uuid,
|
||||
location,
|
||||
domainWithoutWWW(referrer) as source,
|
||||
pathname,
|
||||
href,
|
||||
case
|
||||
when match(user_agent, 'wget|ahrefsbot|curl|urllib|bitdiscovery|\+https://|googlebot')
|
||||
then 'bot'
|
||||
when match(user_agent, 'android')
|
||||
then 'mobile-android'
|
||||
when match(user_agent, 'ipad|iphone|ipod')
|
||||
then 'mobile-ios'
|
||||
else 'desktop'
|
||||
END as device,
|
||||
case
|
||||
when match(user_agent, 'firefox')
|
||||
then 'firefox'
|
||||
when match(user_agent, 'chrome|crios')
|
||||
then 'chrome'
|
||||
when match(user_agent, 'opera')
|
||||
then 'opera'
|
||||
when match(user_agent, 'msie|trident')
|
||||
then 'ie'
|
||||
when match(user_agent, 'iphone|ipad|safari')
|
||||
then 'safari'
|
||||
else 'Unknown'
|
||||
END as browser
|
||||
FROM parsed_hits
|
||||
|
||||
NODE pageviews
|
||||
DESCRIPTION >
|
||||
Group by sessions and calculate metrics at that level
|
||||
|
@ -87,7 +150,7 @@ SQL >
|
|||
case when min(timestamp) = max(timestamp) then 1 else 0 end as is_bounce,
|
||||
max(timestamp) as latest_view_aux,
|
||||
min(timestamp) as first_view_aux
|
||||
from analytics_hits
|
||||
from analytics_hits_data
|
||||
where toDate(timestamp) = {{ Date(date_from) }}
|
||||
group by toStartOfHour(timestamp), session_id, site_uuid, member_status, device, browser, location, source, pathname
|
||||
{% else %}
|
||||
|
|
1
ghost/tinybird/tests/date_range_one_day_kpis.test
Normal file
1
ghost/tinybird/tests/date_range_one_day_kpis.test
Normal file
|
@ -0,0 +1 @@
|
|||
tb pipe data kpis__v${TB_VERSION:-0} --date_from 2100-01-01 --date_to 2100-01-01 --site_uuid mock_site_uuid --format CSV
|
7202
ghost/tinybird/tests/date_range_one_day_kpis.test.result
Normal file
7202
ghost/tinybird/tests/date_range_one_day_kpis.test.result
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue