-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/master' into st_dh_admin…
…_toolbar # Conflicts: # microsetta_private_api/example/client_impl.py
- Loading branch information
Showing
16 changed files
with
364 additions
and
388 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
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- create a column that can be used to record what kit was used | ||
-- when the account was created. | ||
ALTER TABLE ag.account ADD COLUMN created_with_kit_id VARCHAR; | ||
|
||
-- from existing accounts, recover a kit that is associated with | ||
-- the account. if someone has a single kit, then that kit is used | ||
-- and has to be what was registered with. If they have multiple | ||
-- kits, then we'll just pick one of them as in the old system, | ||
-- users would have had to register with each kit individually. | ||
-- This should be suitable for newly created accounts where | ||
-- people have assigned samples. | ||
UPDATE ag.account a SET created_with_kit_id = ss.kit_id | ||
FROM (SELECT s.account_id, (array_agg(supplied_kit_id))[1] AS kit_id | ||
FROM ag.ag_kit ak | ||
JOIN ag.ag_kit_barcodes akb USING (ag_kit_id) | ||
INNER JOIN ag.source s ON (akb.source_id=s.id) | ||
GROUP BY s.account_id) ss | ||
WHERE a.id = ss.account_id; | ||
|
||
-- a large number of kits have samples that were never assigned, | ||
-- which resulted in them not being linked to the "source" table | ||
-- during migration. to handle this, let's use the older links in | ||
-- the database. | ||
UPDATE ag.account SET created_with_kit_id=subquery.kit_id | ||
FROM (SELECT ag_login_id, (array_agg(supplied_kit_id))[1] AS kit_id | ||
FROM ag.account a | ||
JOIN ag.ag_kit ak ON a.id=ak.ag_login_id | ||
JOIN ag.ag_kit_barcodes USING(ag_kit_id) | ||
WHERE created_with_kit_id IS NULL | ||
GROUP BY ag_login_id) AS subquery | ||
WHERE id=subquery.ag_login_id; | ||
|
||
-- finally, there are a handful where the created_with_kit_id remains null. | ||
-- on inspection, this appears to happen in the new system when someone | ||
-- has created an account but hasn't yet claimed samples from a kit. We'll | ||
-- set those to the empty string so that we can make created_with_kit_id | ||
-- not null | ||
UPDATE ag.account SET created_with_kit_id='' | ||
WHERE created_with_kit_id IS NULL; | ||
|
||
ALTER TABLE ag.account ALTER COLUMN created_with_kit_id SET NOT NULL; |
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 @@ | ||
-- users requested that height and weight units come before entering the values | ||
|
||
DO | ||
$do$ | ||
DECLARE | ||
q108 integer; | ||
q109 integer; | ||
q113 integer; | ||
q114 integer; | ||
BEGIN | ||
-- store the current display indices | ||
SELECT display_index INTO q108 FROM ag.group_questions WHERE survey_question_id=108; | ||
SELECT display_index INTO q109 FROM ag.group_questions WHERE survey_question_id=109; | ||
SELECT display_index INTO q113 FROM ag.group_questions WHERE survey_question_id=113; | ||
SELECT display_index INTO q114 FROM ag.group_questions WHERE survey_question_id=114; | ||
|
||
-- set 108 to a temp value, put index from 109 as 108, put index from 108 as 109 | ||
UPDATE ag.group_questions SET display_index=123456 WHERE survey_question_id=108; | ||
UPDATE ag.group_questions SET display_index=q108 WHERE survey_question_id=109; | ||
UPDATE ag.group_questions SET display_index=q109 WHERE survey_question_id=108; | ||
|
||
-- set 113 to a temp value, put index from 114 as 113, put index from 113 as 114 | ||
UPDATE ag.group_questions SET display_index=123456 WHERE survey_question_id=113; | ||
UPDATE ag.group_questions SET display_index=q113 WHERE survey_question_id=114; | ||
UPDATE ag.group_questions SET display_index=q114 WHERE survey_question_id=113; | ||
END $do$; | ||
|
||
-- and add missing birth years... (derived from 0040.sql). This is painful. | ||
ALTER TABLE ag.survey_question_response DROP CONSTRAINT idx_survey_question_response; | ||
UPDATE ag.survey_question_response | ||
SET display_index = display_index + 2 | ||
WHERE survey_question_id = 112 AND response != 'Unspecified'; | ||
ALTER TABLE ag.survey_question_response ADD CONSTRAINT idx_survey_question_response UNIQUE ( survey_question_id, display_index ); | ||
|
||
INSERT INTO ag.survey_response (american, british) VALUES ('2019', '2019'); | ||
INSERT INTO ag.survey_response (american, british) VALUES ('2020', '2020'); | ||
INSERT INTO ag.survey_question_response (survey_question_id, response, display_index, spanish, french, chinese) | ||
VALUES (112, '2020', 1, '2020', '2020', '2020'); | ||
INSERT INTO ag.survey_question_response (survey_question_id, response, display_index, spanish, french, chinese) | ||
VALUES (112, '2019', 2, '2019', '2019', '2019'); |
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
Oops, something went wrong.