Skip to content

Commit

Permalink
chore: Save applicant research opt in query as view (#3996)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Nov 21, 2024
1 parent 5c87e30 commit 06e0175
Show file tree
Hide file tree
Showing 3 changed files with 35 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 @@ -94,6 +94,9 @@
- table:
name: analytics_summary
schema: public
- table:
name: applicant_research_opt_in_view
schema: public
- table:
name: blpu_codes
schema: public
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
comment on view "public"."applicant_research_opt_in_view" is NULL;

DROP VIEW applicant_research_opt_in_view;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE OR REPLACE VIEW applicant_research_opt_in_view AS
WITH data AS (
SELECT
ls.id,
ls.email,
ls.created_at AS application_started_at,
ls.submitted_at,
ls.data->'passport'->'data'->>'applicant.name.last' AS last_name,
ls.data->'passport'->'data'->>'applicant.name.first' AS first_name,
f.name AS flow_name,
t.name AS team_name
FROM
lowcal_sessions ls
JOIN
flows f ON ls.flow_id = f.id
JOIN
teams t ON t.id = f.team_id
WHERE
ls.data->'passport'->'data'->>'applicant.researchOptIn' = '["true"]'
)
SELECT
*
FROM
data
WHERE
last_name IS NOT NULL
AND first_name IS NOT NULL;

comment on view "public"."applicant_research_opt_in_view" is E'Temporary view to expose a list of applicants to opt in to user research during the 2024/25 pilot. Used to generate a CSV report bi-weekly.';

0 comments on commit 06e0175

Please sign in to comment.