Merge pull request #600 from lblod/OP-3784-query-missing-address-uri
Op 3784 query missing address uri
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
|
||||
98
config/reports/organizations-no-address-report.js
Normal file
98
config/reports/organizations-no-address-report.js
Normal file
@@ -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: <http://www.w3.org/ns/org#>
|
||||
PREFIX adms: <http://www.w3.org/ns/adms#>
|
||||
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#>
|
||||
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
||||
SELECT DISTINCT
|
||||
?bestuur
|
||||
?label
|
||||
?classification
|
||||
?status
|
||||
?street
|
||||
?number
|
||||
?bus
|
||||
?postal
|
||||
?location
|
||||
WHERE {
|
||||
?bestuur a org:Organization .
|
||||
|
||||
OPTIONAL {
|
||||
?bestuur <http://www.w3.org/ns/org#hasPrimarySite> ?site .
|
||||
?site <https://data.vlaanderen.be/ns/organisatie#bestaatUit> ?address .
|
||||
OPTIONAL{?address <https://data.vlaanderen.be/ns/adres#verwijstNaar> ?adressenregister .}
|
||||
OPTIONAL{?address <http://www.w3.org/ns/locn#thoroughfare> ?street . }
|
||||
OPTIONAL{?address <https://data.vlaanderen.be/ns/adres#Adresvoorstelling.huisnummer> ?number . }
|
||||
OPTIONAL{?address <https://data.vlaanderen.be/ns/adres#Adresvoorstelling.busnummer> ?bus . }
|
||||
OPTIONAL{?address <http://www.w3.org/ns/locn#postCode> ?postal . }
|
||||
OPTIONAL{?address <https://data.vlaanderen.be/ns/adres#gemeentenaam> ?location . }
|
||||
}
|
||||
|
||||
OPTIONAL {?bestuur skos:prefLabel ?label}
|
||||
OPTIONAL {
|
||||
?bestuur <http://www.w3.org/ns/org#classification> ?org_classification .
|
||||
?org_classification skos:prefLabel ?classification .
|
||||
}
|
||||
OPTIONAL {
|
||||
?bestuur <http://www.w3.org/ns/regorg#orgStatus> ?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}\"`;
|
||||
}
|
||||
Reference in New Issue
Block a user