-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add analytics session ended_at to view
- Found that it wasn't possible to replicate the ["Average time spent"](https://metabase.editor.planx.uk/question/15-average-time-spent?flow_id=0e9d79ec-9cf3-497d-a1a1-8e70469bb52d) card without analytics session ended at - Added this to the view
- Loading branch information
1 parent
751d1dd
commit 138facc
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
....uk/migrations/1702312905340_alter_view_analytics_summary_add_analytics_ended_at/down.sql
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 @@ | ||
DROP VIEW public.analytics_summary CASCADE; |
22 changes: 22 additions & 0 deletions
22
...nx.uk/migrations/1702312905340_alter_view_analytics_summary_add_analytics_ended_at/up.sql
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,22 @@ | ||
CREATE OR REPLACE VIEW "public"."analytics_summary" AS | ||
SELECT a.id AS analytics_id, | ||
al.id AS analytics_log_id, | ||
f.slug AS service_slug, | ||
t.slug AS team_slug, | ||
a.type AS analytics_type, | ||
a.created_at AS analytics_created_at, | ||
a.user_agent, | ||
a.referrer, | ||
al.flow_direction, | ||
al.metadata, | ||
al.user_exit AS is_user_exit, | ||
al.node_type, | ||
al.node_title, | ||
al.has_clicked_help, | ||
al.input_errors, | ||
(date_part('epoch'::text, (al.next_log_created_at - al.created_at)))::numeric(10,1) AS time_spent_on_node_seconds, | ||
a.ended_at AS analytics_ended_at | ||
FROM (((analytics a | ||
LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) | ||
LEFT JOIN flows f ON ((a.flow_id = f.id))) | ||
LEFT JOIN teams t ON ((t.id = f.team_id))); |