Skip to content

Commit

Permalink
chore: Setup feeback_summary relationships and permissions
Browse files Browse the repository at this point in the history
- Rename team -> team_slug
- Add team relationship
- Add permissions
  • Loading branch information
DafyddLlyr committed May 17, 2024
1 parent 8033d92 commit 418cd82
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
70 changes: 70 additions & 0 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,76 @@
- table:
name: feedback_summary
schema: public
object_relationships:
- name: team
using:
manual_configuration:
column_mapping:
team_slug: slug
insertion_order: null
remote_table:
name: teams
schema: public
select_permissions:
- role: platformAdmin
permission:
columns:
- feedback_id
- device
- node_data
- address
- feedback_type
- help_definition
- help_sources
- help_text
- intersecting_constraints
- node_id
- node_text
- node_title
- node_type
- project_type
- service_slug
- status
- team_slug
- uprn
- user_comment
- user_context
- created_at
filter: {}
comment: ""
- role: teamEditor
permission:
columns:
- feedback_id
- device
- node_data
- address
- feedback_type
- help_definition
- help_sources
- help_text
- intersecting_constraints
- node_id
- node_text
- node_title
- node_type
- project_type
- service_slug
- status
- team_slug
- uprn
- user_comment
- user_context
- created_at
filter:
team:
members:
_and:
- user_id:
_eq: x-hasura-user-id
- role:
_eq: teamEditor
comment: ""
- table:
name: feedback_type_enum
schema: public
Expand Down
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 hasura.planx.uk/migrations/1715929881942_run_sql_migration/up.sql
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;

0 comments on commit 418cd82

Please sign in to comment.