From 595afc87ecafd1ae68a83a9136aabcbc47cc583f Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 2 Sep 2024 19:30:21 +0300 Subject: Sort the RIF history data in reverse order. Signed-off-by: Munyoki Kilyungi --- gn3/db/rdf/wiki.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gn3/db') diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py index d8fd8c8..0ff4483 100644 --- a/gn3/db/rdf/wiki.py +++ b/gn3/db/rdf/wiki.py @@ -137,7 +137,7 @@ CONSTRUCT { BIND (COALESCE(?email_, "") AS ?email) . BIND (COALESCE(?species_, "") AS ?species) . BIND (COALESCE(?category_, "") AS ?category) . -} ORDER BY DESC(?version) DESC(?createTime) +} """).substitute(prefix=RDF_PREFIXES, comment_id=comment_id) results = query_frame_and_compact( query, WIKI_CONTEXT, @@ -158,4 +158,9 @@ CONSTRUCT { else: result["pubmed_ids"] = [] result["version"] = int(result["version"]) + # We manually sort the array, since somehow "ORDER BY" in the + # sparql query is jumbled up during framing and compacting. This + # operation isn't heavy since we don't get many versions per wiki + # entry. + results["data"] = sorted(data, key=lambda d: d["version"], reverse=True) return results -- cgit v1.2.3