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) diff --git a/config/reports/organizations-report.js b/config/reports/organizations-report.js index d8e666e..2011077 100644 --- a/config/reports/organizations-report.js +++ b/config/reports/organizations-report.js @@ -1,30 +1,25 @@ -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} SELECT DISTINCT ?bestuur ?label ?classification ?typeEredienst WHERE { - VALUES ?type { - org:Organization - besluit:Bestuurseenheid - } - GRAPH ?g { - ?bestuur a ?type . + ?bestuur a org:Organization . OPTIONAL { ?bestuur skos:prefLabel ?label. } } @@ -44,12 +39,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; }, {}); @@ -59,17 +54,12 @@ export default { SELECT DISTINCT ?bestuur ?provincie WHERE { - VALUES ?type { - org:Organization - besluit:Bestuurseenheid - } - GRAPH ?g { - ?bestuur a ?type . + ?bestuur a org:Organization . } - GRAPH ?h { - OPTIONAL { + OPTIONAL { + GRAPH ?h { ?bestuur org:hasPrimarySite ?primarySite. OPTIONAL { @@ -77,35 +67,37 @@ export default { OPTIONAL { ?sa locn:adminUnitL2 ?provincie. } } } + FILTER (?h IN ( , )) } FILTER (?g IN ( , , )) - FILTER (?h IN ( , , )) + } `; 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; } 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"