X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Ftag.ts;h=c1eebe27f2950f27779ea225c9afd7ee77dabe59;hb=efa3fef23ecf4e1c5289f8715de184c272ea49f7;hp=ed8df8b48aa84367003161035dda9256eac13c76;hpb=8c559fad1e1c4c2ab7f1388c73200aa4c6256d74;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts index ed8df8b48..c1eebe27f 100644 --- a/server/models/video/tag.ts +++ b/server/models/video/tag.ts @@ -1,12 +1,12 @@ -import * as Bluebird from 'bluebird' -import { fn, QueryTypes, Transaction, col } from 'sequelize' +import { col, fn, QueryTypes, Transaction } from 'sequelize' import { AllowNull, BelongsToMany, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' +import { MTag } from '@server/types/models' +import { AttributesOnly } from '@shared/core-utils' +import { VideoPrivacy, VideoState } from '../../../shared/models/videos' import { isVideoTagValid } from '../../helpers/custom-validators/videos' import { throwIfNotValid } from '../utils' import { VideoModel } from './video' import { VideoTagModel } from './video-tag' -import { VideoPrivacy, VideoState } from '../../../shared/models/videos' -import { MTag } from '@server/typings/models' @Table({ tableName: 'tag', @@ -22,7 +22,7 @@ import { MTag } from '@server/typings/models' } ] }) -export class TagModel extends Model { +export class TagModel extends Model>> { @AllowNull(false) @Is('VideoTag', value => throwIfNotValid(value, isVideoTagValid, 'tag')) @@ -45,7 +45,7 @@ export class TagModel extends Model { static findOrCreateTags (tags: string[], transaction: Transaction): Promise { if (tags === null) return Promise.resolve([]) - const tasks: Bluebird[] = [] + const tasks: Promise[] = [] tags.forEach(tag => { const query = { where: { @@ -66,7 +66,7 @@ export class TagModel extends Model { } // threshold corresponds to how many video the field should have to be returned - static getRandomSamples (threshold: number, count: number): Bluebird { + static getRandomSamples (threshold: number, count: number): Promise { const query = 'SELECT tag.name FROM tag ' + 'INNER JOIN "videoTag" ON "videoTag"."tagId" = tag.id ' + 'INNER JOIN video ON video.id = "videoTag"."videoId" ' +