diff options
author | Chocobozzz <me@florianbigard.com> | 2019-09-05 10:19:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-09-05 10:19:35 +0200 |
commit | 00aab0666c6f772548c160fdfa871a8843b88f37 (patch) | |
tree | 73958f6f5d41371980f9653c8cb0ed8f46683c5a /server | |
parent | be04c6fdab5d91a7a57fa3ff36cde22a549c29da (diff) | |
parent | 951532924c1b3fd547cbf45f0c9cf9734203d6b4 (diff) | |
download | PeerTube-00aab0666c6f772548c160fdfa871a8843b88f37.tar.gz PeerTube-00aab0666c6f772548c160fdfa871a8843b88f37.tar.zst PeerTube-00aab0666c6f772548c160fdfa871a8843b88f37.zip |
Merge branch 'release/1.4.0' into develop
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 2 | ||||
-rw-r--r-- | server/models/utils.ts | 10 | ||||
-rw-r--r-- | server/models/video/video-blacklist.ts | 7 |
3 files changed, 9 insertions, 10 deletions
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index d326148d0..1e30f6ebc 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -261,7 +261,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
261 | } | 261 | } |
262 | 262 | ||
263 | private async purgeCacheIfNeeded (candidateToDuplicate: CandidateToDuplicate) { | 263 | private async purgeCacheIfNeeded (candidateToDuplicate: CandidateToDuplicate) { |
264 | while (this.isTooHeavy(candidateToDuplicate)) { | 264 | while (await this.isTooHeavy(candidateToDuplicate)) { |
265 | const redundancy = candidateToDuplicate.redundancy | 265 | const redundancy = candidateToDuplicate.redundancy |
266 | const toDelete = await VideoRedundancyModel.loadOldestLocalExpired(redundancy.strategy, redundancy.minLifetime) | 266 | const toDelete = await VideoRedundancyModel.loadOldestLocalExpired(redundancy.strategy, redundancy.minLifetime) |
267 | if (!toDelete) return | 267 | if (!toDelete) return |
diff --git a/server/models/utils.ts b/server/models/utils.ts index 24890f961..e7e6ddde1 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { Model, Sequelize } from 'sequelize-typescript' | 1 | import { Model, Sequelize } from 'sequelize-typescript' |
2 | import * as validator from 'validator' | 2 | import * as validator from 'validator' |
3 | import { Col } from 'sequelize/types/lib/utils' | 3 | import { Col } from 'sequelize/types/lib/utils' |
4 | import { OrderItem, literal } from 'sequelize' | 4 | import { col, literal, OrderItem } from 'sequelize' |
5 | 5 | ||
6 | type SortType = { sortModel: any, sortValue: string } | 6 | type SortType = { sortModel: string, sortValue: string } |
7 | 7 | ||
8 | // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] | 8 | // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] |
9 | function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { | 9 | function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { |
@@ -51,10 +51,10 @@ function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): Or | |||
51 | return [ firstSort, lastSort ] | 51 | return [ firstSort, lastSort ] |
52 | } | 52 | } |
53 | 53 | ||
54 | function getSortOnModel (model: any, value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { | 54 | function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { |
55 | const [ firstSort ] = getSort(value) | 55 | const [ firstSort ] = getSort(value) |
56 | 56 | ||
57 | if (model) return [ [ model, firstSort[0], firstSort[1] ], lastSort ] | 57 | if (model) return [ [ literal(`"${model}.${firstSort[ 0 ]}" ${firstSort[ 1 ]}`) ], lastSort ] as any[] // FIXME: typings |
58 | return [ firstSort, lastSort ] | 58 | return [ firstSort, lastSort ] |
59 | } | 59 | } |
60 | 60 | ||
@@ -155,7 +155,7 @@ export { | |||
155 | buildLocalAccountIdsIn, | 155 | buildLocalAccountIdsIn, |
156 | getSort, | 156 | getSort, |
157 | getVideoSort, | 157 | getVideoSort, |
158 | getSortOnModel, | 158 | getBlacklistSort, |
159 | createSimilarityAttribute, | 159 | createSimilarityAttribute, |
160 | throwIfNotValid, | 160 | throwIfNotValid, |
161 | buildServerIdsFollowedBy, | 161 | buildServerIdsFollowedBy, |
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index b4df6cd6a..533bfe1ad 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' |
2 | import { getSortOnModel, SortType, throwIfNotValid } from '../utils' | 2 | import { getBlacklistSort, SortType, throwIfNotValid } from '../utils' |
3 | import { VideoModel } from './video' | 3 | import { VideoModel } from './video' |
4 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' | 4 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' |
5 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' | 5 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' |
6 | import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' | 6 | import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' |
7 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 7 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
8 | import { FindOptions } from 'sequelize' | 8 | import { FindOptions, literal } from 'sequelize' |
9 | import { ThumbnailModel } from './thumbnail' | 9 | import { ThumbnailModel } from './thumbnail' |
10 | import * as Bluebird from 'bluebird' | 10 | import * as Bluebird from 'bluebird' |
11 | import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/typings/models' | 11 | import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/typings/models' |
@@ -59,14 +59,13 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> { | |||
59 | return { | 59 | return { |
60 | offset: start, | 60 | offset: start, |
61 | limit: count, | 61 | limit: count, |
62 | order: getSortOnModel(sort.sortModel, sort.sortValue) | 62 | order: getBlacklistSort(sort.sortModel, sort.sortValue) |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | const countQuery = buildBaseQuery() | 66 | const countQuery = buildBaseQuery() |
67 | 67 | ||
68 | const findQuery = buildBaseQuery() | 68 | const findQuery = buildBaseQuery() |
69 | findQuery.subQuery = false | ||
70 | findQuery.include = [ | 69 | findQuery.include = [ |
71 | { | 70 | { |
72 | model: VideoModel, | 71 | model: VideoModel, |