aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-23 11:01:55 +0200
committerChocobozzz <me@florianbigard.com>2022-06-23 11:01:55 +0200
commit371d4c60639e405ce8a503bea1395e9102fbba84 (patch)
tree4235c3534c46f6034db15607623e3aefcf5f56a2
parent64324ac646b0938e35cd88771492623b640bd0d8 (diff)
parentf2623febd8b7b818e47d995ae59f4f1d2f37961b (diff)
downloadPeerTube-371d4c60639e405ce8a503bea1395e9102fbba84.tar.gz
PeerTube-371d4c60639e405ce8a503bea1395e9102fbba84.tar.zst
PeerTube-371d4c60639e405ce8a503bea1395e9102fbba84.zip
Merge branch 'release/4.2.0' into develop
-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)