aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/models/video/tag.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts
index 7900e070d..653b9694b 100644
--- a/server/models/video/tag.ts
+++ b/server/models/video/tag.ts
@@ -45,8 +45,9 @@ export class TagModel extends Model<Partial<AttributesOnly<TagModel>>> {
45 static findOrCreateTags (tags: string[], transaction: Transaction): Promise<MTag[]> { 45 static findOrCreateTags (tags: string[], transaction: Transaction): Promise<MTag[]> {
46 if (tags === null) return Promise.resolve([]) 46 if (tags === null) return Promise.resolve([])
47 47
48 const tasks: Promise<MTag>[] = [] 48 const uniqueTags = new Set(tags)
49 tags.forEach(tag => { 49
50 const tasks = Array.from(uniqueTags).map(tag => {
50 const query = { 51 const query = {
51 where: { 52 where: {
52 name: tag 53 name: tag
@@ -57,9 +58,8 @@ export class TagModel extends Model<Partial<AttributesOnly<TagModel>>> {
57 transaction 58 transaction
58 } 59 }
59 60
60 const promise = TagModel.findOrCreate<MTag>(query) 61 return TagModel.findOrCreate<MTag>(query)
61 .then(([ tagInstance ]) => tagInstance) 62 .then(([ tagInstance ]) => tagInstance)
62 tasks.push(promise)
63 }) 63 })
64 64
65 return Promise.all(tasks) 65 return Promise.all(tasks)