From 32be08bebb6d43c6e446dec12526cd912727c6fb Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 17 Sep 2024 19:37:09 +0300 Subject: Pass in the createtime as an arg when inserting into RDF graph. * gn3/api/metadata_api/wiki.py (edit_wiki): Pass in the createtime as an arg. * gn3/db/rdf/wiki.py: Remove un-used imports. (update_wiki_comment): Use passed in "created" arg in the createtime field. This makes sure that the SQL/RDF timestamps match. Signed-off-by: Munyoki Kilyungi --- gn3/api/metadata_api/wiki.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py index bb7d2d2..8aa0b37 100644 --- a/gn3/api/metadata_api/wiki.py +++ b/gn3/api/metadata_api/wiki.py @@ -25,16 +25,16 @@ def edit_wiki(comment_id: int): # FIXME: attempt to check and fix for types here with relevant errors payload: Dict[str, Any] = request.json # type: ignore pubmed_ids = [str(x) for x in payload.get("pubmed_ids", [])] - + created = datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%d %H:%M:%S" + ) insert_dict = { "Id": comment_id, "symbol": payload["symbol"], "PubMed_ID": " ".join(pubmed_ids), "comment": payload["comment"], "email": payload["email"], - "createtime": datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M" - ), + "createtime": created, "user_ip": request.environ.get("HTTP_X_REAL_IP", request.remote_addr), "weburl": payload.get("web_url"), "initial": payload.get("initial"), @@ -78,6 +78,7 @@ def edit_wiki(comment_id: int): comment_id=comment_id, payload=payload, next_version=next_version, + created=created, sparql_conf={ "sparql_user": current_app.config["SPARQL_USER"], "sparql_password": current_app.config["SPARQL_PASSWORD"], -- cgit v1.2.3