include all tags when filtering by tags
This commit is contained in:
@@ -530,22 +530,22 @@ const eventController = {
|
|||||||
if (!show_recurrent) {
|
if (!show_recurrent) {
|
||||||
where.parentId = null
|
where.parentId = null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end) {
|
if (end) {
|
||||||
where.start_datetime = { [Op.lte]: end }
|
where.start_datetime = { [Op.lte]: end }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const replacements = []
|
||||||
if (tags && places) {
|
if (tags && places) {
|
||||||
where[Op.or] = {
|
where[Op.or] = {
|
||||||
placeId: places ? places.split(',') : [],
|
placeId: places ? places.split(',') : [],
|
||||||
'$tags.tag$': tags.split(',')
|
// '$tags.tag$': Sequelize.literal(`EXISTS (SELECT 1 FROM event_tags WHERE tagTag in ( ${Sequelize.QueryInterface.escape(tags)} ) )`)
|
||||||
}
|
}
|
||||||
}
|
} else if (tags) {
|
||||||
|
// where[Op.and] = Sequelize.literal(`EXISTS (SELECT 1 FROM event_tags WHERE eventId=event.id AND tagTag in (?))`)
|
||||||
if (tags) {
|
where[Op.and] = Sequelize.fn('EXISTS', Sequelize.literal('SELECT 1 FROM event_tags WHERE "event_tags"."eventId"="event".id AND "tagTag" in (?)'))
|
||||||
where['$tags.tag$'] = tags.split(',')
|
replacements.push(tags)
|
||||||
}
|
} else if (places) {
|
||||||
|
|
||||||
if (places) {
|
|
||||||
where.placeId = places.split(',')
|
where.placeId = places.split(',')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,12 +561,12 @@ const eventController = {
|
|||||||
model: Tag,
|
model: Tag,
|
||||||
order: [Sequelize.literal('(SELECT COUNT("tagTag") FROM event_tags WHERE tagTag = tag) DESC')],
|
order: [Sequelize.literal('(SELECT COUNT("tagTag") FROM event_tags WHERE tagTag = tag) DESC')],
|
||||||
attributes: ['tag'],
|
attributes: ['tag'],
|
||||||
required: !!tags,
|
|
||||||
through: { attributes: [] }
|
through: { attributes: [] }
|
||||||
},
|
},
|
||||||
{ model: Place, required: true, attributes: ['id', 'name', 'address'] }
|
{ model: Place, required: true, attributes: ['id', 'name', 'address'] }
|
||||||
],
|
],
|
||||||
limit: max
|
limit: max,
|
||||||
|
replacements
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
log.error('[EVENT]', e)
|
log.error('[EVENT]', e)
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user