-
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.
chore: Setup feeback_summary relationships and permissions
- Rename team -> team_slug - Add team relationship - Add permissions
- Loading branch information
1 parent
8033d92
commit 418cd82
Showing
3 changed files
with
150 additions
and
0 deletions.
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
40 changes: 40 additions & 0 deletions
40
hasura.planx.uk/migrations/1715929881942_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,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; |
40 changes: 40 additions & 0 deletions
40
hasura.planx.uk/migrations/1715929881942_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_slug, | ||
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; |