-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(insights): polishing of multiple breakdowns in Trends (#23649)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ffb7446
commit bc12d36
Showing
14 changed files
with
307 additions
and
77 deletions.
There are no files selected for viewing
Binary file modified
BIN
-1.79 KB
(91%)
...tend/__snapshots__/components-cards-insight-details--trends-world-map--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.89 KB
(90%)
...end/__snapshots__/components-cards-insight-details--trends-world-map--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
SELECT | ||
count() AS total, | ||
toStartOfDay(min_timestamp) AS day_start, | ||
breakdown_value AS breakdown_value | ||
FROM | ||
(SELECT | ||
min(timestamp) AS min_timestamp, | ||
argMin(breakdown_value, timestamp) AS breakdown_value | ||
FROM | ||
(SELECT | ||
person_id, | ||
timestamp, | ||
ifNull(nullIf(toString(properties.$browser), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value | ||
FROM | ||
events AS e SAMPLE 1 | ||
WHERE | ||
and(equals(event, '$pageview'), lessOrEquals(timestamp, assumeNotNull(toDateTime('2025-01-20 23:59:59')))) | ||
) | ||
GROUP BY | ||
person_id | ||
) | ||
WHERE | ||
greaterOrEquals(min_timestamp, toStartOfDay(assumeNotNull(toDateTime('2020-01-09 00:00:00')))) | ||
GROUP BY | ||
day_start, | ||
breakdown_value | ||
LIMIT 50000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
SELECT | ||
arrayMap(number -> plus(toStartOfDay(assumeNotNull(toDateTime('2024-07-16 00:00:00'))), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfDay(assumeNotNull(toDateTime('2024-07-16 00:00:00'))), toStartOfDay(assumeNotNull(toDateTime('2024-07-23 23:59:59'))))), 1))) AS date, | ||
arrayMap(_match_date -> arraySum(arraySlice(groupArray(count), indexOf(groupArray(day_start) AS _days_for_count, _match_date) AS _index, plus(minus(arrayLastIndex(x -> equals(x, _match_date), _days_for_count), _index), 1))), date) AS total | ||
FROM | ||
(SELECT | ||
sum(total) AS count, | ||
day_start | ||
FROM (SELECT | ||
count() AS total, | ||
day_start, | ||
breakdown_value | ||
FROM ( | ||
SELECT | ||
min(timestamp) as day_start, | ||
argMin(breakdown_value, timestamp) AS breakdown_value, | ||
FROM | ||
( | ||
SELECT | ||
person_id, | ||
toStartOfDay(timestamp) AS timestamp, | ||
ifNull(nullIf(toString(person.properties.email), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value | ||
FROM | ||
events AS e SAMPLE 1 | ||
WHERE | ||
and(lessOrEquals(timestamp, assumeNotNull(toDateTime('2024-07-23 23:59:59'))), equals(properties.$browser, 'Safari')) | ||
) | ||
WHERE | ||
greaterOrEquals(timestamp, toStartOfDay(assumeNotNull(toDateTime('2024-07-16 00:00:00')))) | ||
GROUP BY | ||
person_id | ||
) | ||
GROUP BY | ||
day_start, | ||
breakdown_value) | ||
GROUP BY | ||
day_start | ||
ORDER BY | ||
day_start ASC) | ||
ORDER BY | ||
arraySum(total) DESC | ||
LIMIT 50000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
SELECT | ||
arrayMap(number -> plus(toStartOfDay(assumeNotNull(toDateTime('2024-07-16 00:00:00'))), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfDay(assumeNotNull(toDateTime('2024-07-16 00:00:00'))), toStartOfDay(assumeNotNull(toDateTime('2024-07-23 23:59:59'))))), 1))) AS date, | ||
arrayMap(_match_date -> arraySum(arraySlice(groupArray(count), indexOf(groupArray(day_start) AS _days_for_count, _match_date) AS _index, plus(minus(arrayLastIndex(x -> equals(x, _match_date), _days_for_count), _index), 1))), date) AS total | ||
FROM | ||
(SELECT | ||
sum(total) AS count, | ||
day_start | ||
FROM | ||
(SELECT | ||
counts AS total, | ||
toStartOfDay(timestamp) AS day_start | ||
FROM | ||
(SELECT | ||
d.timestamp, | ||
count(DISTINCT actor_id) AS counts | ||
FROM | ||
(SELECT | ||
minus(toStartOfDay(assumeNotNull(toDateTime('2024-07-23 23:59:59'))), toIntervalDay(number)) AS timestamp | ||
FROM | ||
numbers(dateDiff('day', minus(toStartOfDay(assumeNotNull(toDateTime('2024-07-16 00:00:00'))), toIntervalDay(7)), assumeNotNull(toDateTime('2024-07-23 23:59:59')))) AS numbers) AS d | ||
CROSS JOIN (SELECT | ||
timestamp AS timestamp, | ||
e.person_id AS actor_id | ||
FROM | ||
events AS e SAMPLE 1 | ||
WHERE | ||
and(equals(event, '$pageview'), greaterOrEquals(timestamp, minus(assumeNotNull(toDateTime('2024-07-16 00:00:00')), toIntervalDay(7))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2024-07-23 23:59:59')))) | ||
GROUP BY | ||
timestamp, | ||
actor_id) AS e | ||
WHERE | ||
and(lessOrEquals(e.timestamp, plus(d.timestamp, toIntervalDay(1))), greater(e.timestamp, minus(d.timestamp, toIntervalDay(6)))) | ||
GROUP BY | ||
d.timestamp | ||
ORDER BY | ||
d.timestamp ASC) | ||
WHERE | ||
and(greaterOrEquals(timestamp, toStartOfDay(assumeNotNull(toDateTime('2024-07-16 00:00:00')))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2024-07-23 23:59:59'))))) | ||
GROUP BY | ||
day_start | ||
ORDER BY | ||
day_start ASC) | ||
ORDER BY | ||
arraySum(total) DESC | ||
LIMIT 50000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.