about summary refs log tree commit diff
path: root/gn3/db/rdf/wiki.py
diff options
context:
space:
mode:
authorMunyoki Kilyungi2025-04-22 16:39:13 +0300
committerBonfaceKilz2025-04-22 22:47:21 +0300
commit169ea6885f073af851a6ac2166b81f5068c6ef3e (patch)
tree3092cecba04e8be3318b6a413506f4a286538a96 /gn3/db/rdf/wiki.py
parent4aa8d5f1751ba5b994ef09ef8db5c7e4b8747f1c (diff)
downloadgenenetwork3-169ea6885f073af851a6ac2166b81f5068c6ef3e.tar.gz
Add function to delete wiki entries by wiki_id.
* delete_wiki_entries_by_id: New function.

Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/db/rdf/wiki.py')
-rw-r--r--gn3/db/rdf/wiki.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py
index 18d086d..309da73 100644
--- a/gn3/db/rdf/wiki.py
+++ b/gn3/db/rdf/wiki.py
@@ -328,3 +328,31 @@ FROM $graph WHERE {
         )
     results["data"] = data
     return results
+
+
+def delete_wiki_entries_by_id(
+    wiki_id: int,
+    sparql_user: str,
+    sparql_password: str,
+    sparql_auth_uri: str,
+    graph: str = "<http://genenetwork.org>",
+) -> str:
+    """Delete all wiki entries associated with a given ID."""
+    query = Template(
+        """
+$prefix
+
+DELETE WHERE {
+    GRAPH $graph {
+        ?comment dct:identifier \"$wiki_id\"^^xsd:integer .
+        ?comment ?p ?o .
+    }
+}
+"""
+    ).substitute(prefix=RDF_PREFIXES, graph=graph, wiki_id=wiki_id)
+    return update_rdf(
+        query=query,
+        sparql_user=sparql_user,
+        sparql_password=sparql_password,
+        sparql_auth_uri=sparql_auth_uri,
+    )