From ee1c92b5fe130d6727a1ed734f2d9265f5a1e2f1 Mon Sep 17 00:00:00 2001 From: mirdono Date: Tue, 1 Jul 2025 09:48:58 +0200 Subject: [PATCH 1/7] chore: bump report-generation service to latest version This version comes, amongst others, with `curl` installed. This makes it easier to manually trigger the report generation (during development.) --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f1fa41c..de0a4a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -286,7 +286,7 @@ services: restart: always logging: *default-logging report-generation: - image: lblod/loket-report-generation-service:0.7.0 + image: lblod/loket-report-generation-service:0.8.3 environment: DEFAULT_GRAPH: "http://mu.semte.ch/graphs/shared" ONLY_KEEP_LATEST_REPORT: "true" From c6ba52a6bc876513a2efab1ea211a1304519095c Mon Sep 17 00:00:00 2001 From: mirdono Date: Tue, 1 Jul 2025 09:59:40 +0200 Subject: [PATCH 2/7] chore: formatted organisations report configuration --- config/reports/organizations-report.js | 55 +++++++++++++------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/config/reports/organizations-report.js b/config/reports/organizations-report.js index d8e666e..51621f3 100644 --- a/config/reports/organizations-report.js +++ b/config/reports/organizations-report.js @@ -1,17 +1,17 @@ -import { generateReportFromData, batchedQuery } from '../helpers.js'; -import { PREFIXES } from './utils' +import { generateReportFromData, batchedQuery } from "../helpers.js"; +import { PREFIXES } from "./utils"; export default { - cronPattern: '0 00 23 * * *', - name: 'organizations', + cronPattern: "0 00 23 * * *", + name: "organizations", execute: async () => { const reportData = { - title: 'organizations', - description: 'List of the Organizations', - filePrefix: 'exports/organizations' + title: "organizations", + description: "List of the Organizations", + filePrefix: "exports/organizations", }; - console.log('Generating organizations report'); + console.log("Generating organizations report"); const queryStringPart1 = ` ${PREFIXES} @@ -44,12 +44,12 @@ export default { const queryResponsePart1 = await batchedQuery(queryStringPart1); - const dataPart1 = queryResponsePart1.results.bindings.reduce( (acc, row) => { - acc[getSafeValue(row, 'bestuur')] = { - bestuur: getSafeValue(row, 'bestuur'), - label: getSafeValue(row, 'label'), - classification: getSafeValue(row, 'classification'), - typeEredienst: getSafeValue(row, 'typeEredienst'), + const dataPart1 = queryResponsePart1.results.bindings.reduce((acc, row) => { + acc[getSafeValue(row, "bestuur")] = { + bestuur: getSafeValue(row, "bestuur"), + label: getSafeValue(row, "label"), + classification: getSafeValue(row, "classification"), + typeEredienst: getSafeValue(row, "typeEredienst"), }; return acc; }, {}); @@ -85,27 +85,28 @@ export default { `; const queryResponsePart2 = await batchedQuery(queryStringPart2); - const dataPart2 = queryResponsePart2.results.bindings.reduce( (acc, row) => { + const dataPart2 = queryResponsePart2.results.bindings.reduce((acc, row) => { let dataPart = { - bestuur: getSafeValue(row, 'bestuur'), - provincie: getSafeValue(row, 'provincie') + bestuur: getSafeValue(row, "bestuur"), + provincie: getSafeValue(row, "provincie"), }; - acc[getSafeValue(row, 'bestuur')] = Object.assign(dataPart, dataPart1[getSafeValue(row, 'bestuur')]); + acc[getSafeValue(row, "bestuur")] = Object.assign( + dataPart, + dataPart1[getSafeValue(row, "bestuur")], + ); return acc; }, {}); - await generateReportFromData(Object.values(dataPart2), [ - 'bestuur', - 'label', - 'classification', - 'typeEredienst', - 'provincie' - ], reportData); - } + await generateReportFromData( + Object.values(dataPart2), + ["bestuur", "label", "classification", "typeEredienst", "provincie"], + reportData, + ); + }, }; -function getSafeValue(entry, property){ +function getSafeValue(entry, property) { return entry[property] ? wrapInQuote(entry[property].value) : null; } From dc1866251730a8de6ff3f3039718dfa25e6aa321 Mon Sep 17 00:00:00 2001 From: mirdono Date: Tue, 1 Jul 2025 10:04:05 +0200 Subject: [PATCH 3/7] fix: remove unneeded resource type All resources with type `besluit:Bestuurseenheid` also have `org:Organization` as type. Including both types in the queries leads to some organisations, specifically municipalities in the `shared` graph, being included twice in the results. Once with all data and once without label etc. This leads to the results of both queries being incorrectly combined and having entries in the final result without label. --- config/reports/organizations-report.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/reports/organizations-report.js b/config/reports/organizations-report.js index 51621f3..89f1311 100644 --- a/config/reports/organizations-report.js +++ b/config/reports/organizations-report.js @@ -20,7 +20,6 @@ export default { WHERE { VALUES ?type { org:Organization - besluit:Bestuurseenheid } GRAPH ?g { @@ -61,7 +60,6 @@ export default { WHERE { VALUES ?type { org:Organization - besluit:Bestuurseenheid } GRAPH ?g { From a4684811df8c129b0574f5eb3f4a974f7bb2d48d Mon Sep 17 00:00:00 2001 From: mirdono Date: Wed, 2 Jul 2025 09:50:04 +0200 Subject: [PATCH 4/7] refactor: remove `values` clauses with single value --- config/reports/organizations-report.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/config/reports/organizations-report.js b/config/reports/organizations-report.js index 89f1311..66dd2ba 100644 --- a/config/reports/organizations-report.js +++ b/config/reports/organizations-report.js @@ -18,12 +18,8 @@ export default { SELECT DISTINCT ?bestuur ?label ?classification ?typeEredienst WHERE { - VALUES ?type { - org:Organization - } - GRAPH ?g { - ?bestuur a ?type . + ?bestuur a org:Organization . OPTIONAL { ?bestuur skos:prefLabel ?label. } } @@ -58,12 +54,8 @@ export default { SELECT DISTINCT ?bestuur ?provincie WHERE { - VALUES ?type { - org:Organization - } - GRAPH ?g { - ?bestuur a ?type . + ?bestuur a org:Organization . } GRAPH ?h { From 19a0804b56f5fb596ee8e21b1c61fa5f70cd8716 Mon Sep 17 00:00:00 2001 From: mirdono Date: Wed, 2 Jul 2025 13:44:14 +0200 Subject: [PATCH 5/7] chore: remove unnecessary graph The `shared` graph does not contain triples for `org:hasPrimarySite` predicate. --- config/reports/organizations-report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/reports/organizations-report.js b/config/reports/organizations-report.js index 66dd2ba..837c3f8 100644 --- a/config/reports/organizations-report.js +++ b/config/reports/organizations-report.js @@ -70,7 +70,7 @@ export default { } FILTER (?g IN ( , , )) - FILTER (?h IN ( , , )) + FILTER (?h IN ( , )) } `; From 96b36d2cf699d8eac55201e29f9f9ddbbb9d732f Mon Sep 17 00:00:00 2001 From: mirdono Date: Wed, 2 Jul 2025 13:54:41 +0200 Subject: [PATCH 6/7] fix: reorder `graph` and `optional` clauses Putting the optional clause within the graph clause causes to query causes, using DEV data, some organisations to be missed by the query. Turning the order around resolves this without losing any organisations, tested with DEV and PROD data. --- config/reports/organizations-report.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/reports/organizations-report.js b/config/reports/organizations-report.js index 837c3f8..2011077 100644 --- a/config/reports/organizations-report.js +++ b/config/reports/organizations-report.js @@ -58,8 +58,8 @@ export default { ?bestuur a org:Organization . } - GRAPH ?h { - OPTIONAL { + OPTIONAL { + GRAPH ?h { ?bestuur org:hasPrimarySite ?primarySite. OPTIONAL { @@ -67,10 +67,11 @@ export default { OPTIONAL { ?sa locn:adminUnitL2 ?provincie. } } } + FILTER (?h IN ( , )) } FILTER (?g IN ( , , )) - FILTER (?h IN ( , )) + } `; From b6a42c66cf3cebbaa51234d2c3cc608808a4f7f6 Mon Sep 17 00:00:00 2001 From: mirdono Date: Wed, 2 Jul 2025 16:25:56 +0200 Subject: [PATCH 7/7] chore: update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6621622..fcbbf1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,14 @@ - Add Brussel as a municipality [OP-3628] - Bump delta-notifier service to most recent version [OP-3190] - Add URI to resource's organization responses +- Fix query for organizations report [OP-3636] +- Bump report-generation-service to most recent version ### Deploy notes ``` drc pull deltanotifier; drc up -d deltanotifier drc restart migrations-triggering-indexing resource drc pull frontend; drc up -d frontend +drc pull report-generation; drc up -d report-generation ``` ## v1.33.2 (2025-06-20)