Fixed format of events

This commit is contained in:
Torsten Schulz
2024-06-23 17:32:45 +02:00
parent 692e989861
commit 8b89d8b800
26 changed files with 455 additions and 157 deletions

View File

@@ -49,24 +49,21 @@ exports.deleteWorship = async (req, res) => {
};
exports.getFilteredWorships = async (req, res) => {
const { location, orderBy } = req.query;
const { location, order } = req.query;
const where = {};
if (location && location !== '-1') {
if (location.includes('|')) {
const locationsArray = location.split('|');
const locations = JSON.parse(location);
if (location && locations.length > 0) {
where.eventPlaceId = {
[Sequelize.Op.in]: locationsArray
[Sequelize.Op.in]: locations
}
} else {
where.eventPlaceId = location;
}
}
where.date = {
[Op.gte]: new Date(), // Only include events from today onwards
};
console.log(where, order);
try {
const worships = await Worship.findAll({
where,
@@ -74,7 +71,7 @@ exports.getFilteredWorships = async (req, res) => {
model: EventPlace,
as: 'eventPlace',
},
order: [orderBy.split(' ')],
order: [order.split(' ')],
});
res.status(200).json(worships);
} catch (error) {