From 69322042c4da7dddfdccf55efa3cfbf408660d06 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 Jun 2021 14:45:58 +0200 Subject: Cleanup video model scopes --- server/models/video/video.ts | 62 +++++--------------------------------------- 1 file changed, 7 insertions(+), 55 deletions(-) diff --git a/server/models/video/video.ts b/server/models/video/video.ts index f3782fb43..fabfce588 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -56,19 +56,7 @@ import { import { getVideoFileResolution } from '../../helpers/ffprobe-utils' import { logger } from '../../helpers/logger' import { CONFIG } from '../../initializers/config' -import { - ACTIVITY_PUB, - API_VERSION, - CONSTRAINTS_FIELDS, - LAZY_STATIC_PATHS, - STATIC_PATHS, - VIDEO_CATEGORIES, - VIDEO_LANGUAGES, - VIDEO_LICENCES, - VIDEO_PRIVACIES, - VIDEO_STATES, - WEBSERVER -} from '../../initializers/constants' +import { ACTIVITY_PUB, API_VERSION, CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, STATIC_PATHS, WEBSERVER } from '../../initializers/constants' import { sendDeleteVideo } from '../../lib/activitypub/send' import { MChannel, @@ -136,20 +124,16 @@ import { VideoTagModel } from './video-tag' import { VideoViewModel } from './video-view' export enum ScopeNames { - AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', FOR_API = 'FOR_API', WITH_ACCOUNT_DETAILS = 'WITH_ACCOUNT_DETAILS', WITH_TAGS = 'WITH_TAGS', - WITH_TRACKERS = 'WITH_TRACKERS', WITH_WEBTORRENT_FILES = 'WITH_WEBTORRENT_FILES', WITH_SCHEDULED_UPDATE = 'WITH_SCHEDULED_UPDATE', WITH_BLACKLISTED = 'WITH_BLACKLISTED', - WITH_USER_HISTORY = 'WITH_USER_HISTORY', WITH_STREAMING_PLAYLISTS = 'WITH_STREAMING_PLAYLISTS', - WITH_USER_ID = 'WITH_USER_ID', WITH_IMMUTABLE_ATTRIBUTES = 'WITH_IMMUTABLE_ATTRIBUTES', - WITH_THUMBNAILS = 'WITH_THUMBNAILS', - WITH_LIVE = 'WITH_LIVE' + WITH_USER_HISTORY = 'WITH_USER_HISTORY', + WITH_THUMBNAILS = 'WITH_THUMBNAILS' } export type ForAPIOptions = { @@ -245,30 +229,6 @@ export type AvailableForListIDsOptions = { } ] }, - [ScopeNames.WITH_LIVE]: { - include: [ - { - model: VideoLiveModel.unscoped(), - required: false - } - ] - }, - [ScopeNames.WITH_USER_ID]: { - include: [ - { - attributes: [ 'accountId' ], - model: VideoChannelModel.unscoped(), - required: true, - include: [ - { - attributes: [ 'userId' ], - model: AccountModel.unscoped(), - required: true - } - ] - } - ] - }, [ScopeNames.WITH_ACCOUNT_DETAILS]: { include: [ { @@ -326,14 +286,6 @@ export type AvailableForListIDsOptions = { [ScopeNames.WITH_TAGS]: { include: [ TagModel ] }, - [ScopeNames.WITH_TRACKERS]: { - include: [ - { - attributes: [ 'id', 'url' ], - model: TrackerModel - } - ] - }, [ScopeNames.WITH_BLACKLISTED]: { include: [ { @@ -1439,7 +1391,7 @@ export class VideoModel extends Model>> { const rawQuery = `UPDATE "video" SET "${field}" = ` + '(' + - 'SELECT COUNT(id) FROM "accountVideoRate" WHERE "accountVideoRate"."videoId" = "video"."id" AND type = :rateType' + + 'SELECT COUNT(id) FROM "accountVideoRate" WHERE "accountVideoRate"."videoId" = "video"."id" AND type = :rateType' + ') ' + 'WHERE "video"."id" = :videoId' @@ -1467,15 +1419,15 @@ export class VideoModel extends Model>> { .then(results => results.length === 1) } - static bulkUpdateSupportField (videoChannel: MChannel, t: Transaction) { + static bulkUpdateSupportField (ofChannel: MChannel, t: Transaction) { const options = { where: { - channelId: videoChannel.id + channelId: ofChannel.id }, transaction: t } - return VideoModel.update({ support: videoChannel.support }, options) + return VideoModel.update({ support: ofChannel.support }, options) } static getAllIdsFromChannel (videoChannel: MChannelId): Promise { -- cgit v1.2.3