aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2022-01-04 13:21:58 +0300
committerBonfaceKilz2022-01-05 17:05:41 +0300
commit97ca71becd68ed24cd685f359dbe7fc10ffb5bda (patch)
treedc6af83900a5ff8fd235b00c3c18abfd87e49d93 /wqflask
parenta4e76455d79e1c683fcf3fa26d52463d0b54d55a (diff)
downloadgenenetwork2-97ca71becd68ed24cd685f359dbe7fc10ffb5bda.tar.gz
Check for any double-inserts or double-deletions
Track any double-inserts or double-deletions
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/metadata_edits.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index 3d450b36..5b2b1e1d 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -495,18 +495,27 @@ def approve_data(resource_id:str, file_name: str):
value=value,
error=se,
count=count)
+
+ n_deletions = 0
for deletion in (deletions := [d for d in sample_data.get("Deletions")]):
strain_name, _, _, _ = deletion.split(",")
- delete_sample_data(
+ __deletions, _, _ = delete_sample_data(
conn=conn,
trait_name=sample_data.get("trait_name"),
strain_name=strain_name,
phenotype_id=int(sample_data.get("phenotype_id")))
+ if __deletions:
+ n_deletions += 1
+ # Remove any data that already exists from sample_data deletes
+ else:
+ sample_data.get("Deletions").remove(deletion)
+
+ n_insertions = 0
for insertion in (
insertions := [d for d in sample_data.get("Additions")]):
(strain_name,
value, se, count) = insertion.split(",")
- insert_sample_data(
+ __insertions, _, _ = insert_sample_data(
conn=conn,
trait_name=sample_data.get("trait_name"),
strain_name=strain_name,
@@ -516,6 +525,11 @@ def approve_data(resource_id:str, file_name: str):
count=count)
if any([any(modifications), any(deletions), any(insertions)]):
+ if __insertions:
+ n_insertions += 1
+ # Remove any data that already exists from sample_data inserts
+ else:
+ sample_data.get("Additions").remove(insertion)
insert(conn,
table="metadata_audit",
data=MetadataAudit(