Added sorting for events

This commit is contained in:
Torsten Schulz
2025-05-07 12:28:57 +02:00
parent e96dd905b9
commit 63a6cecbb0

View File

@@ -36,6 +36,10 @@ const filterEvents = async (req, res) => {
{ dayOfWeek: { [Op.gte]: 0 } }
]
};
const order = [
['date', 'ASC'],
['time', 'ASC']
];
if (request.id === 'all') {
const events = await Event.findAll({
@@ -46,6 +50,7 @@ const filterEvents = async (req, res) => {
{ model: EventType, as: 'eventType' },
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } }
],
order: order,
logging: console.log // Log the generated SQL query
});
return res.json({ events });
@@ -63,7 +68,7 @@ const filterEvents = async (req, res) => {
{ model: EventType, as: 'eventType' },
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } },
],
order: ['name', 'date', 'time']
order: order,
});
return res.json({ events });
}
@@ -96,7 +101,7 @@ const filterEvents = async (req, res) => {
{ model: EventType, as: 'eventType' },
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } }
],
logging: console.log // Log the generated SQL query
order: order,
});
const displayFields = request.display ? request.display : [];