Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
f2623feb
Verified
Commit
f2623feb
authored
Jun 23, 2022
by
Chocobozzz
Browse files
Fix duplicated tags error
parent
b6898035
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/models/video/tag.ts
View file @
f2623feb
...
...
@@ -45,8 +45,9 @@ export class TagModel extends Model<Partial<AttributesOnly<TagModel>>> {
static
findOrCreateTags
(
tags
:
string
[],
transaction
:
Transaction
):
Promise
<
MTag
[]
>
{
if
(
tags
===
null
)
return
Promise
.
resolve
([])
const
tasks
:
Promise
<
MTag
>
[]
=
[]
tags
.
forEach
(
tag
=>
{
const
uniqueTags
=
new
Set
(
tags
)
const
tasks
=
Array
.
from
(
uniqueTags
).
map
(
tag
=>
{
const
query
=
{
where
:
{
name
:
tag
...
...
@@ -57,9 +58,8 @@ export class TagModel extends Model<Partial<AttributesOnly<TagModel>>> {
transaction
}
const
promise
=
TagModel
.
findOrCreate
<
MTag
>
(
query
)
return
TagModel
.
findOrCreate
<
MTag
>
(
query
)
.
then
(([
tagInstance
])
=>
tagInstance
)
tasks
.
push
(
promise
)
})
return
Promise
.
all
(
tasks
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment