-
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: Save applicant research opt in query as view (#3996)
- Loading branch information
1 parent
5c87e30
commit 06e0175
Showing
3 changed files
with
35 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
3 changes: 3 additions & 0 deletions
3
hasura.planx.uk/migrations/1732184010002_applicant_research_opt_in_view/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 view "public"."applicant_research_opt_in_view" is NULL; | ||
|
||
DROP VIEW applicant_research_opt_in_view; |
29 changes: 29 additions & 0 deletions
29
hasura.planx.uk/migrations/1732184010002_applicant_research_opt_in_view/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,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.'; |