From 38fa2065831b5f55be0d7f30f19a62c967397208 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Nov 2017 14:48:08 +0100 Subject: Remove references to author --- server/models/account/user.ts | 4 +- server/models/index.ts | 1 - server/models/oauth/oauth-token.ts | 4 +- .../models/request/abstract-request-interface.ts | 12 -- server/models/request/index.ts | 5 - server/models/request/request-interface.ts | 46 ----- server/models/request/request-to-pod-interface.ts | 23 --- server/models/request/request-to-pod.ts | 51 ------ .../request/request-video-event-interface.ts | 50 ------ server/models/request/request-video-event.ts | 191 --------------------- .../models/request/request-video-qadu-interface.ts | 48 ------ server/models/request/request-video-qadu.ts | 159 ----------------- server/models/request/request.ts | 144 ---------------- server/models/video/index.ts | 1 - 14 files changed, 4 insertions(+), 735 deletions(-) delete mode 100644 server/models/request/abstract-request-interface.ts delete mode 100644 server/models/request/index.ts delete mode 100644 server/models/request/request-interface.ts delete mode 100644 server/models/request/request-to-pod-interface.ts delete mode 100644 server/models/request/request-to-pod.ts delete mode 100644 server/models/request/request-video-event-interface.ts delete mode 100644 server/models/request/request-video-event.ts delete mode 100644 server/models/request/request-video-qadu-interface.ts delete mode 100644 server/models/request/request-video-qadu.ts delete mode 100644 server/models/request/request.ts (limited to 'server/models') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 1401762c5..7390baf91 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -164,7 +164,7 @@ toFormattedJSON = function (this: UserInstance) { roleLabel: USER_ROLE_LABELS[this.role], videoQuota: this.videoQuota, createdAt: this.createdAt, - author: { + account: { id: this.Account.id, uuid: this.Account.uuid } @@ -295,7 +295,7 @@ function getOriginalVideoFileTotalFromUser (user: UserInstance) { '(SELECT MAX("VideoFiles"."size") AS "size" FROM "VideoFiles" ' + 'INNER JOIN "Videos" ON "VideoFiles"."videoId" = "Videos"."id" ' + 'INNER JOIN "VideoChannels" ON "VideoChannels"."id" = "Videos"."channelId" ' + - 'INNER JOIN "Accounts" ON "VideoChannels"."authorId" = "Accounts"."id" ' + + 'INNER JOIN "Accounts" ON "VideoChannels"."accountId" = "Accounts"."id" ' + 'INNER JOIN "Users" ON "Accounts"."userId" = "Users"."id" ' + 'WHERE "Users"."id" = $userId GROUP BY "Videos"."id") t' diff --git a/server/models/index.ts b/server/models/index.ts index 29479e067..0aec2d3b1 100644 --- a/server/models/index.ts +++ b/server/models/index.ts @@ -2,6 +2,5 @@ export * from './application' export * from './job' export * from './oauth' export * from './pod' -export * from './request' export * from './account' export * from './video' diff --git a/server/models/oauth/oauth-token.ts b/server/models/oauth/oauth-token.ts index dc8bcd872..c7afcc38c 100644 --- a/server/models/oauth/oauth-token.ts +++ b/server/models/oauth/oauth-token.ts @@ -131,7 +131,7 @@ getByTokenAndPopulateUser = function (bearerToken: string) { model: OAuthToken['sequelize'].models.User, include: [ { - model: OAuthToken['sequelize'].models.Author, + model: OAuthToken['sequelize'].models.Account, required: true } ] @@ -156,7 +156,7 @@ getByRefreshTokenAndPopulateUser = function (refreshToken: string) { model: OAuthToken['sequelize'].models.User, include: [ { - model: OAuthToken['sequelize'].models.Author, + model: OAuthToken['sequelize'].models.Account, required: true } ] diff --git a/server/models/request/abstract-request-interface.ts b/server/models/request/abstract-request-interface.ts deleted file mode 100644 index a384f4d27..000000000 --- a/server/models/request/abstract-request-interface.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as Promise from 'bluebird' - -export interface AbstractRequestClass { - countTotalRequests: () => Promise - listWithLimitAndRandom: (limitPods: number, limitRequestsPerPod: number) => Promise - removeWithEmptyTo: () => Promise - removeAll: () => Promise -} - -export interface AbstractRequestToPodClass { - removeByRequestIdsAndPod: (ids: number[], podId: number) => Promise -} diff --git a/server/models/request/index.ts b/server/models/request/index.ts deleted file mode 100644 index 3dd6aedc2..000000000 --- a/server/models/request/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './abstract-request-interface' -export * from './request-interface' -export * from './request-to-pod-interface' -export * from './request-video-event-interface' -export * from './request-video-qadu-interface' diff --git a/server/models/request/request-interface.ts b/server/models/request/request-interface.ts deleted file mode 100644 index dae35651b..000000000 --- a/server/models/request/request-interface.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as Sequelize from 'sequelize' -import * as Promise from 'bluebird' - -import { AbstractRequestClass } from './abstract-request-interface' -import { PodInstance, PodAttributes } from '../pod/pod-interface' -import { RequestEndpoint } from '../../../shared/models/request-scheduler.model' - -export type RequestsGrouped = { - [ podId: number ]: { - request: RequestInstance, - pod: PodInstance - }[] -} - -export namespace RequestMethods { - export type CountTotalRequests = () => Promise - - export type ListWithLimitAndRandom = (limitPods: number, limitRequestsPerPod: number) => Promise - - export type RemoveWithEmptyTo = () => Promise - - export type RemoveAll = () => Promise -} - -export interface RequestClass extends AbstractRequestClass { - countTotalRequests: RequestMethods.CountTotalRequests - listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom - removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo - removeAll: RequestMethods.RemoveAll -} - -export interface RequestAttributes { - request: object - endpoint: RequestEndpoint -} - -export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance { - id: number - createdAt: Date - updatedAt: Date - - setPods: Sequelize.HasManySetAssociationsMixin - Pods: PodInstance[] -} - -export interface RequestModel extends RequestClass, Sequelize.Model {} diff --git a/server/models/request/request-to-pod-interface.ts b/server/models/request/request-to-pod-interface.ts deleted file mode 100644 index 7ca99f4d4..000000000 --- a/server/models/request/request-to-pod-interface.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as Sequelize from 'sequelize' -import * as Promise from 'bluebird' - -import { AbstractRequestToPodClass } from './abstract-request-interface' - -export namespace RequestToPodMethods { - export type RemoveByRequestIdsAndPod = (requestsIds: number[], podId: number) => Promise -} - -export interface RequestToPodClass extends AbstractRequestToPodClass { - removeByRequestIdsAndPod: RequestToPodMethods.RemoveByRequestIdsAndPod -} - -export interface RequestToPodAttributes { -} - -export interface RequestToPodInstance extends RequestToPodClass, RequestToPodAttributes, Sequelize.Instance { - id: number - createdAt: Date - updatedAt: Date -} - -export interface RequestToPodModel extends RequestToPodClass, Sequelize.Model {} diff --git a/server/models/request/request-to-pod.ts b/server/models/request/request-to-pod.ts deleted file mode 100644 index 4e14e918b..000000000 --- a/server/models/request/request-to-pod.ts +++ /dev/null @@ -1,51 +0,0 @@ -import * as Sequelize from 'sequelize' - -import { addMethodsToModel } from '../utils' -import { - RequestToPodInstance, - RequestToPodAttributes, - - RequestToPodMethods -} from './request-to-pod-interface' - -let RequestToPod: Sequelize.Model -let removeByRequestIdsAndPod: RequestToPodMethods.RemoveByRequestIdsAndPod - -export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { - RequestToPod = sequelize.define('RequestToPod', {}, { - indexes: [ - { - fields: [ 'requestId' ] - }, - { - fields: [ 'podId' ] - }, - { - fields: [ 'requestId', 'podId' ], - unique: true - } - ] - }) - - const classMethods = [ - removeByRequestIdsAndPod - ] - addMethodsToModel(RequestToPod, classMethods) - - return RequestToPod -} - -// --------------------------------------------------------------------------- - -removeByRequestIdsAndPod = function (requestsIds: number[], podId: number) { - const query = { - where: { - requestId: { - [Sequelize.Op.in]: requestsIds - }, - podId: podId - } - } - - return RequestToPod.destroy(query) -} diff --git a/server/models/request/request-video-event-interface.ts b/server/models/request/request-video-event-interface.ts deleted file mode 100644 index 26cabe3ba..000000000 --- a/server/models/request/request-video-event-interface.ts +++ /dev/null @@ -1,50 +0,0 @@ -import * as Sequelize from 'sequelize' -import * as Promise from 'bluebird' - -import { AbstractRequestClass, AbstractRequestToPodClass } from './abstract-request-interface' -import { VideoInstance } from '../video/video-interface' -import { PodInstance } from '../pod/pod-interface' - -import { RequestVideoEventType } from '../../../shared/models/request-scheduler.model' - -export type RequestsVideoEventGrouped = { - [ podId: number ]: { - id: number - type: RequestVideoEventType - count: number - video: VideoInstance - pod: PodInstance - }[] -} - -export namespace RequestVideoEventMethods { - export type CountTotalRequests = () => Promise - - export type ListWithLimitAndRandom = (limitPods: number, limitRequestsPerPod: number) => Promise - - export type RemoveByRequestIdsAndPod = (ids: number[], podId: number) => Promise - - export type RemoveAll = () => Promise -} - -export interface RequestVideoEventClass extends AbstractRequestClass, AbstractRequestToPodClass { - countTotalRequests: RequestVideoEventMethods.CountTotalRequests - listWithLimitAndRandom: RequestVideoEventMethods.ListWithLimitAndRandom - removeByRequestIdsAndPod: RequestVideoEventMethods.RemoveByRequestIdsAndPod - removeAll: RequestVideoEventMethods.RemoveAll -} - -export interface RequestVideoEventAttributes { - type: RequestVideoEventType - count: number -} - -export interface RequestVideoEventInstance - extends RequestVideoEventClass, RequestVideoEventAttributes, Sequelize.Instance { - id: number - - Video: VideoInstance -} - -export interface RequestVideoEventModel - extends RequestVideoEventClass, Sequelize.Model {} diff --git a/server/models/request/request-video-event.ts b/server/models/request/request-video-event.ts deleted file mode 100644 index 8954407e1..000000000 --- a/server/models/request/request-video-event.ts +++ /dev/null @@ -1,191 +0,0 @@ -/* - Request Video events (likes, dislikes, views...) -*/ - -import { values } from 'lodash' -import * as Sequelize from 'sequelize' - -import { database as db } from '../../initializers/database' -import { REQUEST_VIDEO_EVENT_TYPES } from '../../initializers' -import { isVideoEventCountValid } from '../../helpers' -import { addMethodsToModel } from '../utils' -import { - RequestVideoEventInstance, - RequestVideoEventAttributes, - - RequestVideoEventMethods, - RequestsVideoEventGrouped -} from './request-video-event-interface' - -let RequestVideoEvent: Sequelize.Model -let countTotalRequests: RequestVideoEventMethods.CountTotalRequests -let listWithLimitAndRandom: RequestVideoEventMethods.ListWithLimitAndRandom -let removeByRequestIdsAndPod: RequestVideoEventMethods.RemoveByRequestIdsAndPod -let removeAll: RequestVideoEventMethods.RemoveAll - -export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { - RequestVideoEvent = sequelize.define('RequestVideoEvent', - { - type: { - type: DataTypes.ENUM(values(REQUEST_VIDEO_EVENT_TYPES)), - allowNull: false - }, - count: { - type: DataTypes.INTEGER, - allowNull: false, - validate: { - countValid: function (value) { - const res = isVideoEventCountValid(value) - if (res === false) throw new Error('Video event count is not valid.') - } - } - } - }, - { - updatedAt: false, - indexes: [ - { - fields: [ 'videoId' ] - } - ] - } - ) - - const classMethods = [ - associate, - - listWithLimitAndRandom, - countTotalRequests, - removeAll, - removeByRequestIdsAndPod - ] - addMethodsToModel(RequestVideoEvent, classMethods) - - return RequestVideoEvent -} - -// ------------------------------ STATICS ------------------------------ - -function associate (models) { - RequestVideoEvent.belongsTo(models.Video, { - foreignKey: { - name: 'videoId', - allowNull: false - }, - onDelete: 'CASCADE' - }) -} - -countTotalRequests = function () { - const query = {} - return RequestVideoEvent.count(query) -} - -listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: number) { - const Pod = db.Pod - - // We make a join between videos and authors to find the podId of our video event requests - const podJoins = 'INNER JOIN "VideoChannels" ON "VideoChannels"."authorId" = "Authors"."id" ' + - 'INNER JOIN "Videos" ON "Videos"."channelId" = "VideoChannels"."id" ' + - 'INNER JOIN "RequestVideoEvents" ON "RequestVideoEvents"."videoId" = "Videos"."id"' - - return Pod.listRandomPodIdsWithRequest(limitPods, 'Authors', podJoins).then(podIds => { - // We don't have friends that have requests - if (podIds.length === 0) return [] - - const query = { - order: [ - [ 'id', 'ASC' ] - ], - include: [ - { - model: RequestVideoEvent['sequelize'].models.Video, - include: [ - { - model: RequestVideoEvent['sequelize'].models.VideoChannel, - include: [ - { - model: RequestVideoEvent['sequelize'].models.Author, - include: [ - { - model: RequestVideoEvent['sequelize'].models.Pod, - where: { - id: { - [Sequelize.Op.in]: podIds - } - } - } - ] - } - ] - } - ] - } - ] - } - - return RequestVideoEvent.findAll(query).then(requests => { - const requestsGrouped = groupAndTruncateRequests(requests, limitRequestsPerPod) - return requestsGrouped - }) - }) -} - -removeByRequestIdsAndPod = function (ids: number[], podId: number) { - const query = { - where: { - id: { - [Sequelize.Op.in]: ids - } - }, - include: [ - { - model: RequestVideoEvent['sequelize'].models.Video, - include: [ - { - model: RequestVideoEvent['sequelize'].models.VideoChannel, - include: [ - { - model: RequestVideoEvent['sequelize'].models.Author, - where: { - podId - } - } - ] - } - ] - } - ] - } - - return RequestVideoEvent.destroy(query) -} - -removeAll = function () { - // Delete all requests - return RequestVideoEvent.truncate({ cascade: true }) -} - -// --------------------------------------------------------------------------- - -function groupAndTruncateRequests (events: RequestVideoEventInstance[], limitRequestsPerPod: number) { - const eventsGrouped: RequestsVideoEventGrouped = {} - - events.forEach(event => { - const pod = event.Video.VideoChannel.Author.Pod - - if (!eventsGrouped[pod.id]) eventsGrouped[pod.id] = [] - - if (eventsGrouped[pod.id].length < limitRequestsPerPod) { - eventsGrouped[pod.id].push({ - id: event.id, - type: event.type, - count: event.count, - video: event.Video, - pod - }) - } - }) - - return eventsGrouped -} diff --git a/server/models/request/request-video-qadu-interface.ts b/server/models/request/request-video-qadu-interface.ts deleted file mode 100644 index b7b7b1ecc..000000000 --- a/server/models/request/request-video-qadu-interface.ts +++ /dev/null @@ -1,48 +0,0 @@ -import * as Sequelize from 'sequelize' -import * as Promise from 'bluebird' - -import { AbstractRequestClass, AbstractRequestToPodClass } from './abstract-request-interface' -import { VideoInstance } from '../video/video-interface' -import { PodInstance } from '../pod/pod-interface' - -import { RequestVideoQaduType } from '../../../shared/models/request-scheduler.model' - -export type RequestsVideoQaduGrouped = { - [ podId: number ]: { - request: RequestVideoQaduInstance - video: VideoInstance - pod: PodInstance - } -} - -export namespace RequestVideoQaduMethods { - export type CountTotalRequests = () => Promise - - export type ListWithLimitAndRandom = (limitPods: number, limitRequestsPerPod: number) => Promise - - export type RemoveByRequestIdsAndPod = (ids: number[], podId: number) => Promise - - export type RemoveAll = () => Promise -} - -export interface RequestVideoQaduClass extends AbstractRequestClass, AbstractRequestToPodClass { - countTotalRequests: RequestVideoQaduMethods.CountTotalRequests - listWithLimitAndRandom: RequestVideoQaduMethods.ListWithLimitAndRandom - removeByRequestIdsAndPod: RequestVideoQaduMethods.RemoveByRequestIdsAndPod - removeAll: RequestVideoQaduMethods.RemoveAll -} - -export interface RequestVideoQaduAttributes { - type: RequestVideoQaduType -} - -export interface RequestVideoQaduInstance - extends RequestVideoQaduClass, RequestVideoQaduAttributes, Sequelize.Instance { - id: number - - Pod: PodInstance - Video: VideoInstance -} - -export interface RequestVideoQaduModel - extends RequestVideoQaduClass, Sequelize.Model {} diff --git a/server/models/request/request-video-qadu.ts b/server/models/request/request-video-qadu.ts deleted file mode 100644 index 93cf249b3..000000000 --- a/server/models/request/request-video-qadu.ts +++ /dev/null @@ -1,159 +0,0 @@ -/* - Request Video for Quick And Dirty Updates like: - - views - - likes - - dislikes - - We can't put it in the same system than basic requests for efficiency. - Moreover we don't want to slow down the basic requests with a lot of views/likes/dislikes requests. - So we put it an independant request scheduler. -*/ - -import { values } from 'lodash' -import * as Sequelize from 'sequelize' - -import { database as db } from '../../initializers/database' -import { REQUEST_VIDEO_QADU_TYPES } from '../../initializers' -import { addMethodsToModel } from '../utils' -import { - RequestVideoQaduInstance, - RequestVideoQaduAttributes, - - RequestVideoQaduMethods -} from './request-video-qadu-interface' - -let RequestVideoQadu: Sequelize.Model -let countTotalRequests: RequestVideoQaduMethods.CountTotalRequests -let listWithLimitAndRandom: RequestVideoQaduMethods.ListWithLimitAndRandom -let removeByRequestIdsAndPod: RequestVideoQaduMethods.RemoveByRequestIdsAndPod -let removeAll: RequestVideoQaduMethods.RemoveAll - -export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { - RequestVideoQadu = sequelize.define('RequestVideoQadu', - { - type: { - type: DataTypes.ENUM(values(REQUEST_VIDEO_QADU_TYPES)), - allowNull: false - } - }, - { - timestamps: false, - indexes: [ - { - fields: [ 'podId' ] - }, - { - fields: [ 'videoId' ] - } - ] - } - ) - - const classMethods = [ - associate, - - listWithLimitAndRandom, - countTotalRequests, - removeAll, - removeByRequestIdsAndPod - ] - addMethodsToModel(RequestVideoQadu, classMethods) - - return RequestVideoQadu -} - -// ------------------------------ STATICS ------------------------------ - -function associate (models) { - RequestVideoQadu.belongsTo(models.Pod, { - foreignKey: { - name: 'podId', - allowNull: false - }, - onDelete: 'CASCADE' - }) - - RequestVideoQadu.belongsTo(models.Video, { - foreignKey: { - name: 'videoId', - allowNull: false - }, - onDelete: 'CASCADE' - }) -} - -countTotalRequests = function () { - const query = {} - return RequestVideoQadu.count(query) -} - -listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: number) { - const Pod = db.Pod - const tableJoin = '' - - return Pod.listRandomPodIdsWithRequest(limitPods, 'RequestVideoQadus', tableJoin).then(podIds => { - // We don't have friends that have requests - if (podIds.length === 0) return [] - - const query = { - include: [ - { - model: RequestVideoQadu['sequelize'].models.Pod, - where: { - id: { - [Sequelize.Op.in]: podIds - } - } - }, - { - model: RequestVideoQadu['sequelize'].models.Video - } - ] - } - - return RequestVideoQadu.findAll(query).then(requests => { - const requestsGrouped = groupAndTruncateRequests(requests, limitRequestsPerPod) - return requestsGrouped - }) - }) -} - -removeByRequestIdsAndPod = function (ids: number[], podId: number) { - const query = { - where: { - id: { - [Sequelize.Op.in]: ids - }, - podId - } - } - - return RequestVideoQadu.destroy(query) -} - -removeAll = function () { - // Delete all requests - return RequestVideoQadu.truncate({ cascade: true }) -} - -// --------------------------------------------------------------------------- - -function groupAndTruncateRequests (requests: RequestVideoQaduInstance[], limitRequestsPerPod: number) { - const requestsGrouped = {} - - requests.forEach(request => { - const pod = request.Pod - - if (!requestsGrouped[pod.id]) requestsGrouped[pod.id] = [] - - if (requestsGrouped[pod.id].length < limitRequestsPerPod) { - requestsGrouped[pod.id].push({ - request: request, - video: request.Video, - pod - }) - } - }) - - return requestsGrouped -} diff --git a/server/models/request/request.ts b/server/models/request/request.ts deleted file mode 100644 index 71118a947..000000000 --- a/server/models/request/request.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { values } from 'lodash' -import * as Sequelize from 'sequelize' - -import { database as db } from '../../initializers/database' -import { REQUEST_ENDPOINTS } from '../../initializers' -import { addMethodsToModel } from '../utils' -import { - RequestInstance, - RequestAttributes, - - RequestMethods, - RequestsGrouped -} from './request-interface' - -let Request: Sequelize.Model -let countTotalRequests: RequestMethods.CountTotalRequests -let listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom -let removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo -let removeAll: RequestMethods.RemoveAll - -export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { - Request = sequelize.define('Request', - { - request: { - type: DataTypes.JSON, - allowNull: false - }, - endpoint: { - type: DataTypes.ENUM(values(REQUEST_ENDPOINTS)), - allowNull: false - } - } - ) - - const classMethods = [ - associate, - - listWithLimitAndRandom, - - countTotalRequests, - removeAll, - removeWithEmptyTo - ] - addMethodsToModel(Request, classMethods) - - return Request -} - -// ------------------------------ STATICS ------------------------------ - -function associate (models) { - Request.belongsToMany(models.Pod, { - foreignKey: { - name: 'requestId', - allowNull: false - }, - through: models.RequestToPod, - onDelete: 'CASCADE' - }) -} - -countTotalRequests = function () { - // We need to include Pod because there are no cascade delete when a pod is removed - // So we could count requests that do not have existing pod anymore - const query = { - include: [ Request['sequelize'].models.Pod ] - } - - return Request.count(query) -} - -listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: number) { - const Pod = db.Pod - const tableJoin = '' - - return Pod.listRandomPodIdsWithRequest(limitPods, 'RequestToPods', tableJoin).then(podIds => { - // We don't have friends that have requests - if (podIds.length === 0) return [] - - // The first x requests of these pods - // It is very important to sort by id ASC to keep the requests order! - const query = { - order: [ - [ 'id', 'ASC' ] - ], - include: [ - { - model: Request['sequelize'].models.Pod, - where: { - id: { - [Sequelize.Op.in]: podIds - } - } - } - ] - } - - return Request.findAll(query).then(requests => { - - const requestsGrouped = groupAndTruncateRequests(requests, limitRequestsPerPod) - return requestsGrouped - }) - }) -} - -removeAll = function () { - // Delete all requests - return Request.truncate({ cascade: true }) -} - -removeWithEmptyTo = function () { - const query = { - where: { - id: { - [Sequelize.Op.notIn]: [ - Sequelize.literal('SELECT "requestId" FROM "RequestToPods"') - ] - } - } - } - - return Request.destroy(query) -} - -// --------------------------------------------------------------------------- - -function groupAndTruncateRequests (requests: RequestInstance[], limitRequestsPerPod: number) { - const requestsGrouped: RequestsGrouped = {} - - requests.forEach(request => { - request.Pods.forEach(pod => { - if (!requestsGrouped[pod.id]) requestsGrouped[pod.id] = [] - - if (requestsGrouped[pod.id].length < limitRequestsPerPod) { - requestsGrouped[pod.id].push({ - request, - pod - }) - } - }) - }) - - return requestsGrouped -} diff --git a/server/models/video/index.ts b/server/models/video/index.ts index dba6a5590..20d97931f 100644 --- a/server/models/video/index.ts +++ b/server/models/video/index.ts @@ -1,4 +1,3 @@ -export * from './author-interface' export * from './tag-interface' export * from './video-abuse-interface' export * from './video-blacklist-interface' -- cgit v1.2.3