about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--uploader/phenotypes/models.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 5acdf60..3e1e31c 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -534,3 +534,25 @@ def quick_save_phenotypes_data(
             ")")
         debug_query(cursor, logger)
         return _count
+
+
+def delete_phenotypes_data(
+        cursor: BaseCursor,
+        data_ids: tuple[int, ...]
+) -> tuple[int, int, int]:
+    """Delete numeric data for phenotypes with the given data IDs."""
+    if len(data_ids) == 0:
+        return (0, 0, 0)
+
+    _paramstr = ", ".join(["%s"] * len(data_ids))
+    cursor.execute(f"DELETE FROM PublishData WHERE Id IN ({_paramstr})",
+                   data_ids)
+    _dcount = cursor.rowcount
+
+    cursor.execute(f"DELETE FROM PublishSE WHERE DataId IN ({_paramstr})",
+                   data_ids)
+    _secount = cursor.rowcount
+    cursor.execute(f"DELETE FROM NStrain WHERE DataId IN ({_paramstr})",
+                   data_ids)
+    _ncount = cursor.rowcount
+    return (_dcount, _secount, _ncount)