chore: formatted organisations report configuration

This commit is contained in:
mirdono
2025-07-01 09:59:40 +02:00
parent ee1c92b5fe
commit c6ba52a6bc

View File

@@ -1,17 +1,17 @@
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}
@@ -44,12 +44,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;
}, {});
@@ -85,27 +85,28 @@ export default {
`;
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;
}