Skip to content

Commit

Permalink
Merge branch 'biocore:master' into vocab_samples_issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ayobi authored Jun 6, 2024
2 parents 109d988 + b9f678e commit a6b9023
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ci/conda_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
flake8
psycopg2
flask
flask < 3.0.0
natsort
pycryptodome
pandas < 2.0.0
werkzeug < 3.0.0
92 changes: 92 additions & 0 deletions microsetta_private_api/db/patches/0139.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
-- This database patch copies two samples into new barcodes to reflect
-- adjustments that were necessary in the wet lab. We don't believe this
-- will be an ongoing need, but if it proves to be, check for new
-- barcode-related tables before using this as a template.

-- Begin copying X00236845 to 0364352596
INSERT INTO barcodes.barcode (barcode, assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id)
SELECT '0364352596', assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id
FROM barcodes.barcode
WHERE barcode = 'X00236845';

INSERT INTO barcodes.project_barcode (project_id, barcode)
SELECT project_id, '0364352596'
FROM barcodes.project_barcode
WHERE barcode = 'X00236845';

-- I'm omitting the sample_barcode_file and sample_barcode_file_md5 as they're
-- no longer used and it would be inappropriate to directly clone a different
-- barcode's associated file.
INSERT INTO ag.ag_kit_barcodes (ag_kit_id, barcode, site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update)
SELECT ag_kit_id, '0364352596', site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update
FROM ag.ag_kit_barcodes
WHERE barcode = 'X00236845';

INSERT INTO ag.source_barcodes_surveys (barcode, survey_id)
SELECT '0364352596', survey_id
FROM ag.source_barcodes_surveys
WHERE barcode = 'X00236845';

INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, technician_notes)
SELECT '0364352596', scan_timestamp, sample_status, technician_notes
FROM barcodes.barcode_scans
WHERE barcode = 'X00236845';

INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code)
WITH temp_1 AS (
SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code
FROM ag.vioscreen_registry vr
INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id
WHERE akb.barcode = 'X00236845'
),
temp_2 AS (
SELECT ag_kit_barcode_id
FROM ag.ag_kit_barcodes
WHERE barcode = '0364352596'
)
SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2;
-- End copying X00236845 to 0364352596

-- Begin copying 000031307 to 0364406520
INSERT INTO barcodes.barcode (barcode, assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id)
SELECT '0364406520', assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id
FROM barcodes.barcode
WHERE barcode = '000031307';

INSERT INTO barcodes.project_barcode (project_id, barcode)
SELECT project_id, '0364406520'
FROM barcodes.project_barcode
WHERE barcode = '000031307';

-- I'm omitting the sample_barcode_file and sample_barcode_file_md5 as they're
-- no longer used and it would be inappropriate to directly clone a different
-- barcode's associated file.
INSERT INTO ag.ag_kit_barcodes (ag_kit_id, barcode, site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update)
SELECT ag_kit_id, '0364406520', site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update
FROM ag.ag_kit_barcodes
WHERE barcode = '000031307';

INSERT INTO ag.source_barcodes_surveys (barcode, survey_id)
SELECT '0364406520', survey_id
FROM ag.source_barcodes_surveys
WHERE barcode = '000031307';

INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, technician_notes)
SELECT '0364406520', scan_timestamp, sample_status, technician_notes
FROM barcodes.barcode_scans
WHERE barcode = '000031307';

INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code)
WITH temp_1 AS (
SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code
FROM ag.vioscreen_registry vr
INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id
WHERE akb.barcode = '000031307'
),
temp_2 AS (
SELECT ag_kit_barcode_id
FROM ag.ag_kit_barcodes
WHERE barcode = '0364406520'
)
SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2;
-- End copying 000031307 to 0364406520
3 changes: 3 additions & 0 deletions microsetta_private_api/model/account.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum
from microsetta_private_api.model.model_base import ModelBase
from microsetta_private_api.model.address import Address
from microsetta_private_api.localization import EN_US, JA_JP


class AuthorizationMatch(Enum):
Expand Down Expand Up @@ -61,6 +62,8 @@ def __init__(self, account_id, email,
self.creation_time = creation_time
self.update_time = update_time
self.language = language
if (self.language == JA_JP):
self.language = EN_US
self.consent_privacy_terms = consent_privacy_terms

def to_api(self):
Expand Down
4 changes: 3 additions & 1 deletion microsetta_private_api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from microsetta_private_api.repo.transaction import Transaction
from microsetta_private_api.repo.admin_repo import AdminRepo
from microsetta_private_api.repo.qiita_repo import QiitaRepo
from microsetta_private_api.localization import EN_US
from microsetta_private_api.localization import EN_US, JA_JP
from microsetta_private_api.config_manager import SERVER_CONFIG
import pandas as pd
import tempfile
Expand All @@ -22,6 +22,8 @@
@celery.task(ignore_result=True)
def send_email(email, template_name, template_args, language):
template = EmailMessage[template_name]
if language == JA_JP:
language = EN_US

with flask_babel.force_locale(language):
SendEmail.send(email, template, template_args)
Expand Down

0 comments on commit a6b9023

Please sign in to comment.