-
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.
feat: add & populate column
analytics_logs.node_id
(#2576)
- Loading branch information
1 parent
fc08523
commit 507dd50
Showing
6 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
- id | ||
- input_errors | ||
- metadata | ||
- node_id | ||
- node_title | ||
- node_type | ||
- user_exit | ||
|
1 change: 1 addition & 0 deletions
1
...uk/migrations/1702897470388_alter_table_public_analytics_logs_add_column_node_id/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 @@ | ||
alter table "public"."analytics_logs" drop column "node_id"; |
1 change: 1 addition & 0 deletions
1
...x.uk/migrations/1702897470388_alter_table_public_analytics_logs_add_column_node_id/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 @@ | ||
alter table "public"."analytics_logs" add column "node_id" text null; |
24 changes: 24 additions & 0 deletions
24
hasura.planx.uk/migrations/1702899813258_update_view_analytics_summary_node_id/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,24 @@ | ||
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, | ||
user_agent, | ||
referrer, | ||
flow_direction, | ||
metadata, | ||
al.user_exit as is_user_exit, | ||
node_type, | ||
node_title, | ||
has_clicked_help, | ||
input_errors, | ||
CAST(EXTRACT(EPOCH FROM (al.next_log_created_at - al.created_at)) as numeric (10, 1)) as time_spent_on_node_seconds, | ||
a.ended_at as analytics_ended_at, | ||
CAST(EXTRACT(EPOCH FROM (a.ended_at - a.created_at))/60 as numeric (10, 1)) as time_spent_on_analytics_session_minutes | ||
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; |
25 changes: 25 additions & 0 deletions
25
hasura.planx.uk/migrations/1702899813258_update_view_analytics_summary_node_id/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,25 @@ | ||
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, | ||
user_agent, | ||
referrer, | ||
flow_direction, | ||
metadata, | ||
al.user_exit as is_user_exit, | ||
node_type, | ||
node_title, | ||
has_clicked_help, | ||
input_errors, | ||
CAST(EXTRACT(EPOCH FROM (al.next_log_created_at - al.created_at)) as numeric (10, 1)) as time_spent_on_node_seconds, | ||
a.ended_at as analytics_ended_at, | ||
CAST(EXTRACT(EPOCH FROM (a.ended_at - a.created_at))/60 as numeric (10, 1)) as time_spent_on_analytics_session_minutes, | ||
node_id | ||
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; |