Fixed format of events
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user