From 970ceac0a6bf4990b8924738591df4949491ec9b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 1 Aug 2019 10:15:28 +0200 Subject: Fix multiple server tests --- server/models/account/account-video-rate.ts | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'server/models/account/account-video-rate.ts') diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 85af9e378..d5c214ecb 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts @@ -89,6 +89,25 @@ export class AccountVideoRateModel extends Model { return AccountVideoRateModel.findOne(options) } + static loadByAccountAndVideoOrUrl (accountId: number, videoId: number, url: string, transaction?: Transaction) { + const options: FindOptions = { + where: { + [ Op.or]: [ + { + accountId, + videoId + }, + { + url + } + ] + } + } + if (transaction) options.transaction = transaction + + return AccountVideoRateModel.findOne(options) + } + static listByAccountForApi (options: { start: number, count: number, @@ -202,6 +221,23 @@ export class AccountVideoRateModel extends Model { videoId, type }, + include: [ + { + model: AccountModel.unscoped(), + required: true, + include: [ + { + model: ActorModel.unscoped(), + required: true, + where: { + serverId: { + [Op.ne]: null + } + } + } + ] + } + ], transaction: t } -- cgit v1.2.3