-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Capture node_data
directly alongside feeback
#3156
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -239,6 +239,7 @@ | |
- feedback_type | ||
- flow_id | ||
- id | ||
- node_data | ||
- node_id | ||
- node_type | ||
- status | ||
|
3 changes: 3 additions & 0 deletions
3
...anx.uk/migrations/1715867685564_alter_table_public_feedback_add_column_node_data/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,3 @@ | ||
comment on column "public"."feedback"."node_data" is NULL; | ||
|
||
ALTER TABLE feedback DROP COLUMN node_data; |
4 changes: 4 additions & 0 deletions
4
...planx.uk/migrations/1715867685564_alter_table_public_feedback_add_column_node_data/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,4 @@ | ||
alter table "public"."feedback" add column "node_data" jsonb | ||
null; | ||
|
||
comment on column "public"."feedback"."node_data" is E'The data of the node the user was on when their feedback was left'; |
54 changes: 54 additions & 0 deletions
54
hasura.planx.uk/migrations/1715868696352_run_sql_migration/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,54 @@ | ||
DROP VIEW "public"."feedback_summary"; | ||
|
||
-- Most recent version of view from planx-new/hasura.planx.uk/migrations/1715784133713_run_sql_migration/up.sql | ||
CREATE OR REPLACE VIEW "public"."feedback_summary" AS | ||
SELECT | ||
fb.id AS feedback_id, | ||
t.slug AS team, | ||
f.slug AS service_slug, | ||
fb.created_at, | ||
fb.node_id, | ||
fb.device, | ||
fb.user_context, | ||
fb.user_comment, | ||
fb.feedback_type, | ||
fb.status, | ||
fb.node_type, | ||
COALESCE( | ||
published_flow_node.data ->> 'title', | ||
published_flow_node.data ->> 'text', | ||
published_flow_node.data ->> 'flagSet' | ||
) AS node_title, | ||
published_flow_node.data ->> 'description' AS node_text, | ||
published_flow_node.data ->> 'info' AS help_text, | ||
published_flow_node.data ->> 'policyRef' AS help_sources, | ||
published_flow_node.data ->> 'howMeasured' AS help_definition, | ||
COALESCE( | ||
fb.user_data -> 'passport' -> 'data' -> '_address' ->> 'single_line_address', | ||
fb.user_data -> 'passport' -> 'data' -> '_address' ->> 'title' | ||
) AS address, | ||
(fb.user_data -> 'passport' -> 'data' -> '_address' ->> 'uprn') AS uprn, | ||
(fb.user_data -> 'passport' -> 'data' ->> 'proposal.projectType') AS project_type, | ||
(fb.user_data -> 'passport' -> 'data' ->> 'property.constraints.planning') AS intersecting_constraints, | ||
published_flow_node.data AS node_data | ||
FROM | ||
feedback fb | ||
LEFT JOIN | ||
flows f ON f.id = fb.flow_id | ||
LEFT JOIN | ||
teams t ON t.id = fb.team_id | ||
LEFT JOIN LATERAL | ||
( | ||
SELECT | ||
(published_flows.data -> fb.node_id) -> 'data' AS data | ||
FROM | ||
published_flows | ||
WHERE | ||
published_flows.flow_id = fb.flow_id | ||
AND published_flows.created_at < fb.created_at | ||
ORDER BY | ||
published_flows.created_at DESC | ||
LIMIT 1 | ||
) AS published_flow_node ON true; | ||
|
||
GRANT SELECT ON public.feedback_summary TO metabase_read_only; |
40 changes: 40 additions & 0 deletions
40
hasura.planx.uk/migrations/1715868696352_run_sql_migration/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,40 @@ | ||
DROP VIEW "public"."feedback_summary"; | ||
|
||
CREATE OR REPLACE VIEW "public"."feedback_summary" AS | ||
SELECT | ||
fb.id AS feedback_id, | ||
t.slug AS team, | ||
f.slug AS service_slug, | ||
fb.created_at, | ||
fb.node_id, | ||
fb.device, | ||
fb.user_context, | ||
fb.user_comment, | ||
fb.feedback_type, | ||
fb.status, | ||
fb.node_type, | ||
fb.node_data, | ||
COALESCE( | ||
fb.node_data ->> 'title', | ||
fb.node_data ->> 'text', | ||
fb.node_data ->> 'flagSet' | ||
) AS node_title, | ||
fb.node_data ->> 'description' AS node_text, | ||
fb.node_data ->> 'info' AS help_text, | ||
fb.node_data ->> 'policyRef' AS help_sources, | ||
fb.node_data ->> 'howMeasured' AS help_definition, | ||
COALESCE( | ||
fb.user_data -> 'passport' -> 'data' -> '_address' ->> 'single_line_address', | ||
fb.user_data -> 'passport' -> 'data' -> '_address' ->> 'title' | ||
) AS address, | ||
(fb.user_data -> 'passport' -> 'data' -> '_address' ->> 'uprn') AS uprn, | ||
(fb.user_data -> 'passport' -> 'data' ->> 'proposal.projectType') AS project_type, | ||
(fb.user_data -> 'passport' -> 'data' ->> 'property.constraints.planning') AS intersecting_constraints | ||
FROM | ||
feedback fb | ||
LEFT JOIN | ||
flows f ON f.id = fb.flow_id | ||
LEFT JOIN | ||
teams t ON t.id = fb.team_id; | ||
|
||
GRANT SELECT ON public.feedback_summary TO metabase_read_only; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯