Merge pull request #593 from lblod/OP-3758-Add-column-to-query-organizations-in-Dashboard

OP-3758: updated organizations-report query + fix to dev migration
This commit is contained in:
Damon Kennes
2026-04-17 10:13:38 +02:00
committed by GitHub
2 changed files with 47 additions and 73 deletions

View File

@@ -1,6 +1,5 @@
DELETE { DELETE {
GRAPH ?g { GRAPH ?g {
?s a <http://www.w3.org/ns/org#Organization>.
?s <http://www.w3.org/ns/regorg#orgStatus> ?status. ?s <http://www.w3.org/ns/regorg#orgStatus> ?status.
} }
} }

View File

@@ -6,92 +6,67 @@ export default {
name: "organizations", name: "organizations",
execute: async () => { execute: async () => {
const reportData = { const reportData = {
title: "organizations", title: "organisations in database",
description: "List of the Organizations", description: "List of the Organisations in the database",
filePrefix: "exports/organizations", filePrefix: "exports/organizations",
}; };
console.log("Generating organizations report"); console.log("Generating organizations report");
const queryStringPart1 = ` const queryString = `
${PREFIXES} ${PREFIXES}
PREFIX org: <http://www.w3.org/ns/org#>
SELECT DISTINCT ?bestuur ?label ?classification ?typeEredienst 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
?typeEredienst
?provincie
?status
WHERE { WHERE {
GRAPH ?g {
?bestuur a org:Organization . ?bestuur a org:Organization .
OPTIONAL { ?bestuur skos:prefLabel ?label. }
}
OPTIONAL { OPTIONAL {
?bestuur org:classification ?classificationUri . ?bestuur <http://www.w3.org/ns/org#hasPrimarySite> ?site.
?classificationUri skos:prefLabel ?classification. ?site <https://data.vlaanderen.be/ns/organisatie#bestaatUit> ?address.
?address <http://www.w3.org/ns/locn#adminUnitL2> ?provincie
} }
OPTIONAL {?bestuur <http://data.lblod.info/vocabularies/erediensten/typeEredienst> ?typeEredienst.}
OPTIONAL {?bestuur skos:prefLabel ?label}
OPTIONAL { OPTIONAL {
?bestuur ere:typeEredienst ?typeEredienstUri. ?bestuur <http://www.w3.org/ns/org#classification> ?org_classification .
?typeEredienstUri skos:prefLabel ?typeEredienst. ?org_classification skos:prefLabel ?classification
}
OPTIONAL {
?bestuur <http://www.w3.org/ns/regorg#orgStatus> ?org_status.
?org_status skos:prefLabel ?status.
} }
FILTER (?g IN ( <http://mu.semte.ch/graphs/administrative-unit>, <http://mu.semte.ch/graphs/worship-service>, <http://mu.semte.ch/graphs/shared>))
} }
`; `;
const queryResponsePart1 = await batchedQuery(queryStringPart1); const queryResponse = await batchedQuery(queryString);
const dataPart1 = queryResponsePart1.results.bindings.reduce((acc, row) => { const data = queryResponse.results.bindings.map((row) => ({
acc[getSafeValue(row, "bestuur")] = { "bestuur": getSafeValue(row, "bestuur"),
bestuur: getSafeValue(row, "bestuur"), "label": getSafeValue(row, "label"),
label: getSafeValue(row, "label"), "classification": getSafeValue(row, "classification"),
classification: getSafeValue(row, "classification"), "typeEredienst": getSafeValue(row, "typeEredienst"),
typeEredienst: getSafeValue(row, "typeEredienst"), "provincie": getSafeValue(row, "provincie"),
}; "status": getSafeValue(row, "status"),
return acc; }));
}, {});
const queryStringPart2 = `
${PREFIXES}
SELECT DISTINCT ?bestuur ?provincie
WHERE {
GRAPH ?g {
?bestuur a org:Organization .
}
OPTIONAL {
GRAPH ?h {
?bestuur org:hasPrimarySite ?primarySite.
OPTIONAL {
?primarySite organisatie:bestaatUit ?sa.
OPTIONAL { ?sa locn:adminUnitL2 ?provincie. }
}
}
FILTER (?h IN ( <http://mu.semte.ch/graphs/administrative-unit>, <http://mu.semte.ch/graphs/worship-service> ))
}
FILTER (?g IN ( <http://mu.semte.ch/graphs/administrative-unit>, <http://mu.semte.ch/graphs/worship-service>, <http://mu.semte.ch/graphs/shared>))
}
`;
const queryResponsePart2 = await batchedQuery(queryStringPart2);
const dataPart2 = queryResponsePart2.results.bindings.reduce((acc, row) => {
let dataPart = {
bestuur: getSafeValue(row, "bestuur"),
provincie: getSafeValue(row, "provincie"),
};
acc[getSafeValue(row, "bestuur")] = Object.assign(
dataPart,
dataPart1[getSafeValue(row, "bestuur")],
);
return acc;
}, {});
await generateReportFromData( await generateReportFromData(
Object.values(dataPart2), data,
["bestuur", "label", "classification", "typeEredienst", "provincie"], [
"bestuur",
"label",
"classification",
"typeEredienst",
"provincie",
"status",
],
reportData, reportData,
); );
}, },