From ef65d3f9ddf39383925bb067d74c21a63cb90708 Mon Sep 17 00:00:00 2001 From: lesion Date: Tue, 25 Jan 2022 01:30:47 +0100 Subject: [PATCH] fix tags/places filters --- server/api/controller/event.js | 16 ++++++++++++---- server/api/controller/export.js | 18 ++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/server/api/controller/event.js b/server/api/controller/event.js index 9469a9c7..2cea8f9c 100644 --- a/server/api/controller/event.js +++ b/server/api/controller/event.js @@ -504,12 +504,20 @@ const eventController = { where.start_datetime = { [Op.lte]: end } } - if (places || tags) { + if (tags && places) { where[Op.or] = { - placeId: places ? places.split(',') : [], - '$tags.tag$': tags ? tags.split(',') : [] - } + placeId: places ? places.split(',') : [], + '$tags.tag$': tags.split(',') } + } + + if (tags) { + where['$tags.tag$'] = tags.split(',') + } + + if (places) { + where.placeId = places.split(',') + } const events = await Event.findAll({ where, diff --git a/server/api/controller/export.js b/server/api/controller/export.js index 7850c4f3..4c9cc360 100644 --- a/server/api/controller/export.js +++ b/server/api/controller/export.js @@ -17,12 +17,22 @@ const exportController = { const where = {} const yesterday = moment().subtract('1', 'day').unix() - if (places || tags) { + + if (tags && places) { where[Op.or] = { - placeId: places ? places.split(',') : [], - '$tags.tag$': tags ? tags.split(',') : [] - } + placeId: places ? places.split(',') : [], + '$tags.tag$': tags.split(',') } + } + + if (tags) { + where['$tags.tag$'] = tags.split(',') + } + + if (places) { + where.placeId = places.split(',') + } + if (!show_recurrent) { where.parentId = null }