added missing pages
This commit is contained in:
@@ -77,25 +77,25 @@ const filterContactPersons = async (req, res) => {
|
||||
console.log(configString, typeof configString);
|
||||
const config = JSON.parse(configString);
|
||||
const where = {};
|
||||
const having = [];
|
||||
|
||||
console.log(config, typeof config);
|
||||
console.log(config.selection);
|
||||
if (config.selection.id && config.selection.id === 'all') {
|
||||
// No additional filter needed for "all"
|
||||
} else if (config.selection.id) {
|
||||
where.id = config.selection.id;
|
||||
} else {
|
||||
const filters = [];
|
||||
|
||||
if (config.selection.types && config.selection.types.length > 0) {
|
||||
filters.push({ '$positions.id$': { [Op.in]: config.selection.types } });
|
||||
having.push({ '$positions.id$': { [Op.in]: config.selection.types } });
|
||||
}
|
||||
|
||||
if (config.selection.places && config.selection.places.length > 0) {
|
||||
filters.push({ '$events.eventPlaceId$': { [Op.in]: config.selection.places } });
|
||||
having.push({ '$events.eventPlaceId$': { [Op.in]: config.selection.places } });
|
||||
}
|
||||
|
||||
if (filters.length > 0) {
|
||||
where[Op.and] = filters;
|
||||
if (config.selection.positions && config.selection.positions.length > 0) {
|
||||
having.push({ '$positions.id$': { [Op.in]: config.selection.positions } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,13 +106,16 @@ const filterContactPersons = async (req, res) => {
|
||||
model: Position,
|
||||
as: 'positions',
|
||||
through: { attributes: [] },
|
||||
required: true, // Ensure only contact persons with matching positions are included
|
||||
},
|
||||
{
|
||||
model: Event,
|
||||
as: 'events',
|
||||
through: { attributes: [] },
|
||||
required: false,
|
||||
},
|
||||
],
|
||||
having: having.length > 0 ? { [Op.and]: having } : undefined,
|
||||
});
|
||||
|
||||
res.json(contactPersons);
|
||||
|
||||
Reference in New Issue
Block a user