Skip to content

Commit

Permalink
fix: Order cubes by version history and by desc(iri) to select newest…
Browse files Browse the repository at this point in the history
… cube
  • Loading branch information
bprusinowski committed Oct 26, 2023
1 parent f8fbe2f commit fbba91b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/rdf/query-search.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import RDF from "@rdfjs/data-model";
import { SELECT } from "@tpluscode/sparql-builder";
import { descending, group } from "d3";
import { Literal, NamedNode } from "rdf-js";
Expand Down Expand Up @@ -201,7 +202,11 @@ export const searchCubes = async ({
)`
: ""
}
`.prologue`${pragmas}`;
`
.ORDER()
// Important for the latter part of the query, to return the latest cube per unversioned iri.
.BY(RDF.variable("versionHistory"))
.THEN.BY(RDF.variable("iri"), true).prologue`${pragmas}`;

const scoreResults = await scoresQuery.execute(sparqlClient.query, {
operation: "postUrlencoded",
Expand Down

0 comments on commit fbba91b

Please sign in to comment.