Skip to content

Commit

Permalink
feat: First pass at analytics view
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Nov 18, 2023
1 parent 44a5be8 commit a660eda
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
- user_exit
filter: {}
check: null
- table:
schema: public
name: analytics_summary
- table:
schema: public
name: blpu_codes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW public.analytics_summary;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 as user_agent,
a.referrer as referrer,
al.flow_direction as flow_direction,
al.metadata as metadata,
al.user_exit as is_user_exit,
al.node_type as node_type,
al.node_title as node_title,
al.has_clicked_help as has_clicked_help,
CAST(EXTRACT(EPOCH FROM (al.next_log_created_at - al.created_at)) as numeric (10, 1)) as time_spent_on_node_seconds
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;

0 comments on commit a660eda

Please sign in to comment.