From 5b2a1b1ac6ee8592a9b278d9d58adbec788123e0 Mon Sep 17 00:00:00 2001 From: Damon Date: Wed, 22 Apr 2026 10:17:03 +0200 Subject: [PATCH 1/3] OP-3774: added new query/report for organizations shown in frontend --- CHANGELOG.md | 1 + config/reports/index.js | 2 + .../organizations-in-frontend-report.js | 102 ++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 config/reports/organizations-in-frontend-report.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 5beca2b..3bede03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add column to query organizations in Dashboard [OP-3758] - Query list change events of organisations in Dashboard [OP-3760] - Disable SPARQL endpoint +- Create new query 'organisations shown in OP frontend' in Dashboard [OP-3774] ### Deploy notes ``` diff --git a/config/reports/index.js b/config/reports/index.js index a24f3da..b085078 100644 --- a/config/reports/index.js +++ b/config/reports/index.js @@ -5,6 +5,7 @@ import OrganizationsDetailReport from './organizations-detail-report' import OrganizationsPlatformReport from './organizations-platform-report' import AdministrativeUnitsReport from "./administrative-units-report"; import ChangeEventsReport from "./change-events-report"; +import OrganizationsInFrontendReport from "./organizations-in-frontend-report"; export default [ OrganizationsReport, @@ -14,4 +15,5 @@ export default [ OrganizationsPlatformReport, AdministrativeUnitsReport, ChangeEventsReport, + OrganizationsInFrontendReport ]; diff --git a/config/reports/organizations-in-frontend-report.js b/config/reports/organizations-in-frontend-report.js new file mode 100644 index 0000000..543aea3 --- /dev/null +++ b/config/reports/organizations-in-frontend-report.js @@ -0,0 +1,102 @@ +import { generateReportFromData, batchedQuery } from "../helpers.js"; +import { PREFIXES } from "./utils"; + +export default { + cronPattern: "0 00 23 * * *", + name: "organizationsInFrontend", + execute: async () => { + const reportData = { + title: "organisations in frontend", + description: "List of the Organisations shown in the frontend", + filePrefix: "exports/organizations InFrontend", + }; + + console.log("Generating organizations in frontend report"); + + const queryString = ` + ${PREFIXES} + PREFIX org: + PREFIX adms: + PREFIX generiek: + PREFIX skos: + PREFIX geosparql: + PREFIX dct: + SELECT DISTINCT + ?bestuur + ?label + ?classification + ?typeEredienst + ?provincie + ?status + WHERE { + ?bestuur a org:Organization . + OPTIONAL { + ?bestuur ?site. + ?site ?address. + ?address ?provincie + } + OPTIONAL {?bestuur ?typeEredienst.} + OPTIONAL {?bestuur skos:prefLabel ?label} + OPTIONAL { + ?bestuur ?org_classification . + ?org_classification skos:prefLabel ?classification + } + OPTIONAL { + ?bestuur ?org_status. + ?org_status skos:prefLabel ?status. + } + + FILTER( + NOT EXISTS { + ?bestuur org:classification + } + || + EXISTS { + ?bestuur besluit:werkingsgebied ?werkingsgebied . + ?werkingsgebied geosparql:sfWithin ?parent . + } + ) + + FILTER( + NOT EXISTS { + ?bestuur org:classification + } + + ) + } + `; + + const queryResponse = await batchedQuery(queryString); + + const data = queryResponse.results.bindings.map((row) => ({ + "bestuur": getSafeValue(row, "bestuur"), + "label": getSafeValue(row, "label"), + "classification": getSafeValue(row, "classification"), + "typeEredienst": getSafeValue(row, "typeEredienst"), + "provincie": getSafeValue(row, "provincie"), + "status": getSafeValue(row, "status"), + })); + + await generateReportFromData( + data, + [ + "bestuur", + "label", + "classification", + "typeEredienst", + "provincie", + "status", + ], + reportData, + ); + }, +}; + +function getSafeValue(entry, property) { + return entry[property] ? wrapInQuote(entry[property].value) : null; +} + +// Some values might contain commas; wrapping them in escapes quotes doesn't disrupt the columns. +function wrapInQuote(value) { + return `\"${value}\"`; +} From a79d080eb4de7cc9b94c1f462cc61a1fabe70582 Mon Sep 17 00:00:00 2001 From: Damon Date: Mon, 4 May 2026 13:43:54 +0200 Subject: [PATCH 2/3] OP-3774: fix to query --- .../organizations-in-frontend-report.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/config/reports/organizations-in-frontend-report.js b/config/reports/organizations-in-frontend-report.js index 543aea3..1a76c9b 100644 --- a/config/reports/organizations-in-frontend-report.js +++ b/config/reports/organizations-in-frontend-report.js @@ -8,7 +8,7 @@ export default { const reportData = { title: "organisations in frontend", description: "List of the Organisations shown in the frontend", - filePrefix: "exports/organizations InFrontend", + filePrefix: "exports/organizationsInFrontend", }; console.log("Generating organizations in frontend report"); @@ -33,13 +33,13 @@ export default { OPTIONAL { ?bestuur ?site. ?site ?address. - ?address ?provincie + ?address ?provincie. } OPTIONAL {?bestuur ?typeEredienst.} OPTIONAL {?bestuur skos:prefLabel ?label} OPTIONAL { ?bestuur ?org_classification . - ?org_classification skos:prefLabel ?classification + ?org_classification skos:prefLabel ?classification. } OPTIONAL { ?bestuur ?org_status. @@ -48,7 +48,7 @@ export default { FILTER( NOT EXISTS { - ?bestuur org:classification + ?bestuur org:classification . } || EXISTS { @@ -59,7 +59,7 @@ export default { FILTER( NOT EXISTS { - ?bestuur org:classification + ?bestuur org:classification . } ) @@ -69,12 +69,12 @@ export default { const queryResponse = await batchedQuery(queryString); const data = queryResponse.results.bindings.map((row) => ({ - "bestuur": getSafeValue(row, "bestuur"), - "label": getSafeValue(row, "label"), - "classification": getSafeValue(row, "classification"), - "typeEredienst": getSafeValue(row, "typeEredienst"), - "provincie": getSafeValue(row, "provincie"), - "status": getSafeValue(row, "status"), + bestuur: getSafeValue(row, "bestuur"), + label: getSafeValue(row, "label"), + classification: getSafeValue(row, "classification"), + typeEredienst: getSafeValue(row, "typeEredienst"), + provincie: getSafeValue(row, "provincie"), + status: getSafeValue(row, "status"), })); await generateReportFromData( From d95b331c9972e0eff50dd9aad6430000d9b0c18b Mon Sep 17 00:00:00 2001 From: Damon Date: Mon, 4 May 2026 13:59:34 +0200 Subject: [PATCH 3/3] OP-3774: filePrefix edit --- config/reports/organizations-in-frontend-report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/reports/organizations-in-frontend-report.js b/config/reports/organizations-in-frontend-report.js index 1a76c9b..0da92cc 100644 --- a/config/reports/organizations-in-frontend-report.js +++ b/config/reports/organizations-in-frontend-report.js @@ -8,7 +8,7 @@ export default { const reportData = { title: "organisations in frontend", description: "List of the Organisations shown in the frontend", - filePrefix: "exports/organizationsInFrontend", + filePrefix: "exports/organizations-in-frontend", }; console.log("Generating organizations in frontend report");