diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-20 09:19:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-20 11:05:45 +0200 |
commit | 8054669f1181e815c435e76e81247eff32d41dc5 (patch) | |
tree | 6938a880d7e71a132fa0fc5adf143a21a8b9f938 /server/controllers/api/videos | |
parent | 1c58423f6c42f494ea6358043bcb5a735b7bd5d7 (diff) | |
download | PeerTube-8054669f1181e815c435e76e81247eff32d41dc5.tar.gz PeerTube-8054669f1181e815c435e76e81247eff32d41dc5.tar.zst PeerTube-8054669f1181e815c435e76e81247eff32d41dc5.zip |
Optimize default sort when listing videos
createdAt does not have the appropriate index
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/index.ts | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 1dfd7c7a0..c05acfd2f 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -1,11 +1,24 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { move } from 'fs-extra' | ||
2 | import { extname } from 'path' | 3 | import { extname } from 'path' |
4 | import toInt from 'validator/lib/toInt' | ||
5 | import { addOptimizeOrMergeAudioJob } from '@server/helpers/video' | ||
6 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | ||
7 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' | ||
8 | import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' | ||
9 | import { getVideoFilePath } from '@server/lib/video-paths' | ||
10 | import { getServerActor } from '@server/models/application/application' | ||
11 | import { MVideoDetails, MVideoFullLight } from '@server/types/models' | ||
3 | import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' | 12 | import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' |
13 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | ||
14 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' | ||
15 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | ||
16 | import { resetSequelizeInstance } from '../../../helpers/database-utils' | ||
17 | import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils' | ||
4 | import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 18 | import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
5 | import { logger } from '../../../helpers/logger' | 19 | import { logger } from '../../../helpers/logger' |
6 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | ||
7 | import { getFormattedObjects } from '../../../helpers/utils' | 20 | import { getFormattedObjects } from '../../../helpers/utils' |
8 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | 21 | import { CONFIG } from '../../../initializers/config' |
9 | import { | 22 | import { |
10 | DEFAULT_AUDIO_RESOLUTION, | 23 | DEFAULT_AUDIO_RESOLUTION, |
11 | MIMETYPES, | 24 | MIMETYPES, |
@@ -14,9 +27,15 @@ import { | |||
14 | VIDEO_LICENCES, | 27 | VIDEO_LICENCES, |
15 | VIDEO_PRIVACIES | 28 | VIDEO_PRIVACIES |
16 | } from '../../../initializers/constants' | 29 | } from '../../../initializers/constants' |
30 | import { sequelizeTypescript } from '../../../initializers/database' | ||
31 | import { sendView } from '../../../lib/activitypub/send/send-view' | ||
17 | import { federateVideoIfNeeded, fetchRemoteVideoDescription } from '../../../lib/activitypub/videos' | 32 | import { federateVideoIfNeeded, fetchRemoteVideoDescription } from '../../../lib/activitypub/videos' |
18 | import { JobQueue } from '../../../lib/job-queue' | 33 | import { JobQueue } from '../../../lib/job-queue' |
34 | import { Notifier } from '../../../lib/notifier' | ||
35 | import { Hooks } from '../../../lib/plugins/hooks' | ||
19 | import { Redis } from '../../../lib/redis' | 36 | import { Redis } from '../../../lib/redis' |
37 | import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' | ||
38 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | ||
20 | import { | 39 | import { |
21 | asyncMiddleware, | 40 | asyncMiddleware, |
22 | asyncRetryTransactionMiddleware, | 41 | asyncRetryTransactionMiddleware, |
@@ -26,7 +45,7 @@ import { | |||
26 | optionalAuthenticate, | 45 | optionalAuthenticate, |
27 | paginationValidator, | 46 | paginationValidator, |
28 | setDefaultPagination, | 47 | setDefaultPagination, |
29 | setDefaultSort, | 48 | setDefaultVideosSort, |
30 | videoFileMetadataGetValidator, | 49 | videoFileMetadataGetValidator, |
31 | videosAddValidator, | 50 | videosAddValidator, |
32 | videosCustomGetValidator, | 51 | videosCustomGetValidator, |
@@ -35,37 +54,18 @@ import { | |||
35 | videosSortValidator, | 54 | videosSortValidator, |
36 | videosUpdateValidator | 55 | videosUpdateValidator |
37 | } from '../../../middlewares' | 56 | } from '../../../middlewares' |
57 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | ||
38 | import { TagModel } from '../../../models/video/tag' | 58 | import { TagModel } from '../../../models/video/tag' |
39 | import { VideoModel } from '../../../models/video/video' | 59 | import { VideoModel } from '../../../models/video/video' |
40 | import { VideoFileModel } from '../../../models/video/video-file' | 60 | import { VideoFileModel } from '../../../models/video/video-file' |
41 | import { abuseVideoRouter } from './abuse' | 61 | import { abuseVideoRouter } from './abuse' |
42 | import { blacklistRouter } from './blacklist' | 62 | import { blacklistRouter } from './blacklist' |
43 | import { videoCommentRouter } from './comment' | ||
44 | import { rateVideoRouter } from './rate' | ||
45 | import { ownershipVideoRouter } from './ownership' | ||
46 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' | ||
47 | import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils' | ||
48 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | ||
49 | import { videoCaptionsRouter } from './captions' | 63 | import { videoCaptionsRouter } from './captions' |
64 | import { videoCommentRouter } from './comment' | ||
50 | import { videoImportsRouter } from './import' | 65 | import { videoImportsRouter } from './import' |
51 | import { resetSequelizeInstance } from '../../../helpers/database-utils' | 66 | import { ownershipVideoRouter } from './ownership' |
52 | import { move } from 'fs-extra' | 67 | import { rateVideoRouter } from './rate' |
53 | import { watchingRouter } from './watching' | 68 | import { watchingRouter } from './watching' |
54 | import { Notifier } from '../../../lib/notifier' | ||
55 | import { sendView } from '../../../lib/activitypub/send/send-view' | ||
56 | import { CONFIG } from '../../../initializers/config' | ||
57 | import { sequelizeTypescript } from '../../../initializers/database' | ||
58 | import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' | ||
59 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | ||
60 | import { Hooks } from '../../../lib/plugins/hooks' | ||
61 | import { MVideoDetails, MVideoFullLight } from '@server/types/models' | ||
62 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | ||
63 | import { getVideoFilePath } from '@server/lib/video-paths' | ||
64 | import toInt from 'validator/lib/toInt' | ||
65 | import { addOptimizeOrMergeAudioJob } from '@server/helpers/video' | ||
66 | import { getServerActor } from '@server/models/application/application' | ||
67 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' | ||
68 | import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' | ||
69 | 69 | ||
70 | const auditLogger = auditLoggerFactory('videos') | 70 | const auditLogger = auditLoggerFactory('videos') |
71 | const videosRouter = express.Router() | 71 | const videosRouter = express.Router() |
@@ -105,7 +105,7 @@ videosRouter.get('/privacies', listVideoPrivacies) | |||
105 | videosRouter.get('/', | 105 | videosRouter.get('/', |
106 | paginationValidator, | 106 | paginationValidator, |
107 | videosSortValidator, | 107 | videosSortValidator, |
108 | setDefaultSort, | 108 | setDefaultVideosSort, |
109 | setDefaultPagination, | 109 | setDefaultPagination, |
110 | optionalAuthenticate, | 110 | optionalAuthenticate, |
111 | commonVideosFiltersValidator, | 111 | commonVideosFiltersValidator, |