From dabb7727b618ccacc462154aa2e30df42519e006 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 23 Jan 2026 11:50:21 -0600 Subject: Add function to delete numeric data for phenotypes. --- uploader/phenotypes/models.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'uploader') 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) -- cgit 1.4.1