diff options
| author | Frederick Muriuki Muriithi | 2026-01-23 11:50:21 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-01-23 11:50:21 -0600 |
| commit | dabb7727b618ccacc462154aa2e30df42519e006 (patch) | |
| tree | 851028aa297799ebc6dc8fa5a80e0a5b196b4671 | |
| parent | 1777492fa65164c7ba66f5aa0c594fbc169bf519 (diff) | |
| download | gn-uploader-dabb7727b618ccacc462154aa2e30df42519e006.tar.gz | |
Add function to delete numeric data for phenotypes.
| -rw-r--r-- | uploader/phenotypes/models.py | 22 |
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) |
