From eb90f88b0e1a0eba1ad22dea30b7a312758b4531 Mon Sep 17 00:00:00 2001 From: Sam Van Campenhout Date: Thu, 9 Sep 2021 15:52:23 +0200 Subject: [PATCH] Make sure financing percentages are sorted as expected It seems that something in the Semantic Works stack doesn't handle sorting values with the xsd:floats type properly. The frontend receives the records in the wrong order. Explicitly converting the floats to a xsd:decimal solves the problem so we use that as a workaround for now. --- ...09152600-fix-percentage-sort-part-1.sparql | 22 +++++++++++++++++++ ...09152630-fix-percentage-sort-part-2.sparql | 19 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 config/migrations/20210909152600-fix-percentage-sort-part-1.sparql create mode 100644 config/migrations/20210909152630-fix-percentage-sort-part-2.sparql diff --git a/config/migrations/20210909152600-fix-percentage-sort-part-1.sparql b/config/migrations/20210909152600-fix-percentage-sort-part-1.sparql new file mode 100644 index 0000000..348b6b8 --- /dev/null +++ b/config/migrations/20210909152600-fix-percentage-sort-part-1.sparql @@ -0,0 +1,22 @@ +PREFIX xsd: +PREFIX ere: +PREFIX ext: + +# Convert the xsd:float typed percentages to xsd:decimal. +# This is needed to work around a sorting issue that only happens with xsd:float. +# The migration file is split up in 2 parts since Virtuoso has issues with doing the conversion in a single migration file. + +DELETE { + GRAPH ?g { + ?s ere:financieringspercentage ?percentage. + } +} INSERT { + GRAPH ?g { + ?s ext:decimalPercentage ?decimalPercentage. + } +} WHERE { + GRAPH ?g { + ?s ere:financieringspercentage ?percentage. + BIND (ROUND(xsd:decimal(?percentage)*100)/100 AS ?decimalPercentage). + } +} \ No newline at end of file diff --git a/config/migrations/20210909152630-fix-percentage-sort-part-2.sparql b/config/migrations/20210909152630-fix-percentage-sort-part-2.sparql new file mode 100644 index 0000000..99b8fdf --- /dev/null +++ b/config/migrations/20210909152630-fix-percentage-sort-part-2.sparql @@ -0,0 +1,19 @@ +PREFIX xsd: +PREFIX ere: +PREFIX ext: + +# Part 2 of the percentage sort fix. + +DELETE { + GRAPH ?g { + ?s ext:decimalPercentage ?percentage. + } +} INSERT { + GRAPH ?g { + ?s ere:financieringspercentage ?percentage. + } +} WHERE { + GRAPH ?g { + ?s ext:decimalPercentage ?percentage. + } +} \ No newline at end of file