From 969e5184c0af49e9a800112c0e348f124ab2f608 Mon Sep 17 00:00:00 2001 From: lesion Date: Wed, 22 Jun 2022 15:30:13 +0200 Subject: [PATCH] fix add / modify event with duplicated tag --- server/api/controller/tag.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/api/controller/tag.js b/server/api/controller/tag.js index b8574d69..1f2f882b 100644 --- a/server/api/controller/tag.js +++ b/server/api/controller/tag.js @@ -1,5 +1,6 @@ const Tag = require('../models/tag') const Event = require('../models/event') +const uniq = require('lodash/uniq') const { where, fn, col, Op } = require('sequelize') const exportController = require('./export') @@ -14,7 +15,7 @@ module.exports = { // search for already existing tags (tag is the same as TaG) const existingTags = await Tag.findAll({ where: { [Op.and]: where(fn('LOWER', col('tag')), { [Op.in]: lowercaseTags }) } }) const lowercaseExistingTags = existingTags.map(t => t.tag.toLocaleLowerCase()) - const remainingTags = trimmedTags.filter(t => ! lowercaseExistingTags.includes(t.toLocaleLowerCase())) + const remainingTags = uniq(trimmedTags.filter(t => ! lowercaseExistingTags.includes(t.toLocaleLowerCase()))) // create remaining tags (cannot use updateOnDuplicate or manage conflicts) return [].concat(