aboutsummaryrefslogtreecommitdiff
path: root/uploader/phenotypes/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/phenotypes/models.py')
-rw-r--r--uploader/phenotypes/models.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 2843d06..3e749c0 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -303,9 +303,13 @@ def create_new_phenotypes(conn: mdb.Connection,
cursor.executemany(
("INSERT INTO "
"Phenotype(Pre_publication_description, Original_description, Units, Authorized_Users) "
- "VALUES (%(id)s, %(description)s, %(units)s, 'robwilliams') "
- "RETURNING *"),
+ "VALUES (%(id)s, %(description)s, %(units)s, 'robwilliams')"),
tuple(batch))
+ paramstr = ", ".join(["%s"] * len(batch))
+ cursor.execute(
+ "SELECT * FROM Phenotype WHERE Pre_publication_description IN "
+ f"({paramstr})",
+ tuple(item["id"] for item in batch))
_phenos = _phenos + tuple({
"phenotype_id": row["Id"],
"id": row["Pre_publication_description"],
@@ -343,6 +347,14 @@ def save_phenotypes_data(
"RETURNING *"),
tuple(batch))
+ paramstr = ", ".join(["(%s, %s)"] * len(batch))
+ cursor.execute(f"SELECT * FROM {_table_details['table']} "
+ f"WHERE ({_table_details['DataIdCol']}, StrainId) "
+ f"IN ({paramstr})",
+ tuple(single for items in
+ ((item["data_id"], item["sample_id"])
+ for item in batch)
+ for single in items))
saved_data = saved_data + tuple(dict(row) for row in cursor.fetchall())
return saved_data