diff --git a/CHANGELOG.md b/CHANGELOG.md index 20899c9..2715c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ # Changelog ## Unreleased +- Query to check missing address URI's [OP-3784] - Create new query 'organisations shown in OP frontend' in Dashboard [OP-3774] ### Deploy notes ``` -drc restart report-generation +drc restart report-generation ``` ## 1.39.1 (2026-04-24) diff --git a/config/reports/index.js b/config/reports/index.js index b085078..e3ceb4b 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 OrganizationsNoAddressReport from "./organizations-no-address-report"; import OrganizationsInFrontendReport from "./organizations-in-frontend-report"; export default [ @@ -15,5 +16,6 @@ export default [ OrganizationsPlatformReport, AdministrativeUnitsReport, ChangeEventsReport, - OrganizationsInFrontendReport + OrganizationsNoAddressReport, + OrganizationsInFrontendReport, ]; diff --git a/config/reports/organizations-no-address-report.js b/config/reports/organizations-no-address-report.js new file mode 100644 index 0000000..5685e5d --- /dev/null +++ b/config/reports/organizations-no-address-report.js @@ -0,0 +1,98 @@ +import { generateReportFromData, batchedQuery } from "../helpers.js"; +import { PREFIXES } from "./utils"; + +export default { + cronPattern: "0 00 23 * * *", + name: "organizationsNoAddressregister", + execute: async () => { + const reportData = { + title: "missing address URI's", + description: "List of Organizations with addresses that have no address URI", + filePrefix: "exports/organizations-no-addressregister", + }; + + console.log("Generating organizations no addressregister report"); + + const queryString = ` + ${PREFIXES} + PREFIX org: + PREFIX adms: + PREFIX generiek: + PREFIX skos: + SELECT DISTINCT + ?bestuur + ?label + ?classification + ?status + ?street + ?number + ?bus + ?postal + ?location + WHERE { + ?bestuur a org:Organization . + + OPTIONAL { + ?bestuur ?site . + ?site ?address . + OPTIONAL{?address ?adressenregister .} + OPTIONAL{?address ?street . } + OPTIONAL{?address ?number . } + OPTIONAL{?address ?bus . } + OPTIONAL{?address ?postal . } + OPTIONAL{?address ?location . } + } + + OPTIONAL {?bestuur skos:prefLabel ?label} + OPTIONAL { + ?bestuur ?org_classification . + ?org_classification skos:prefLabel ?classification . + } + OPTIONAL { + ?bestuur ?org_status . + ?org_status skos:prefLabel ?status . + } + FILTER(!BOUND(?adressenregister)) + } + `; + + const queryResponse = await batchedQuery(queryString); + + const data = queryResponse.results.bindings.map((row) => ({ + bestuur: getSafeValue(row, "bestuur"), + label: getSafeValue(row, "label"), + classification: getSafeValue(row, "classification"), + status: getSafeValue(row, "status"), + street: getSafeValue(row, "street"), + number: getSafeValue(row, "number"), + bus: getSafeValue(row, "bus"), + postal: getSafeValue(row, "postal"), + location: getSafeValue(row, "location"), + })); + + await generateReportFromData( + data, + [ + "bestuur", + "label", + "classification", + "status", + "street", + "number", + "bus", + "postal", + "location", + ], + 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}\"`; +}