aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-20 09:19:21 +0200
committerChocobozzz <me@florianbigard.com>2020-08-20 11:05:45 +0200
commit8054669f1181e815c435e76e81247eff32d41dc5 (patch)
tree6938a880d7e71a132fa0fc5adf143a21a8b9f938 /server/controllers/api/videos
parent1c58423f6c42f494ea6358043bcb5a735b7bd5d7 (diff)
downloadPeerTube-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.ts54
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { move } from 'fs-extra'
2import { extname } from 'path' 3import { extname } from 'path'
4import toInt from 'validator/lib/toInt'
5import { addOptimizeOrMergeAudioJob } from '@server/helpers/video'
6import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
7import { changeVideoChannelShare } from '@server/lib/activitypub/share'
8import { getVideoActivityPubUrl } from '@server/lib/activitypub/url'
9import { getVideoFilePath } from '@server/lib/video-paths'
10import { getServerActor } from '@server/models/application/application'
11import { MVideoDetails, MVideoFullLight } from '@server/types/models'
3import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' 12import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared'
13import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
14import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
15import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
16import { resetSequelizeInstance } from '../../../helpers/database-utils'
17import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils'
4import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 18import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
5import { logger } from '../../../helpers/logger' 19import { logger } from '../../../helpers/logger'
6import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
7import { getFormattedObjects } from '../../../helpers/utils' 20import { getFormattedObjects } from '../../../helpers/utils'
8import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' 21import { CONFIG } from '../../../initializers/config'
9import { 22import {
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'
30import { sequelizeTypescript } from '../../../initializers/database'
31import { sendView } from '../../../lib/activitypub/send/send-view'
17import { federateVideoIfNeeded, fetchRemoteVideoDescription } from '../../../lib/activitypub/videos' 32import { federateVideoIfNeeded, fetchRemoteVideoDescription } from '../../../lib/activitypub/videos'
18import { JobQueue } from '../../../lib/job-queue' 33import { JobQueue } from '../../../lib/job-queue'
34import { Notifier } from '../../../lib/notifier'
35import { Hooks } from '../../../lib/plugins/hooks'
19import { Redis } from '../../../lib/redis' 36import { Redis } from '../../../lib/redis'
37import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail'
38import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
20import { 39import {
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'
57import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
38import { TagModel } from '../../../models/video/tag' 58import { TagModel } from '../../../models/video/tag'
39import { VideoModel } from '../../../models/video/video' 59import { VideoModel } from '../../../models/video/video'
40import { VideoFileModel } from '../../../models/video/video-file' 60import { VideoFileModel } from '../../../models/video/video-file'
41import { abuseVideoRouter } from './abuse' 61import { abuseVideoRouter } from './abuse'
42import { blacklistRouter } from './blacklist' 62import { blacklistRouter } from './blacklist'
43import { videoCommentRouter } from './comment'
44import { rateVideoRouter } from './rate'
45import { ownershipVideoRouter } from './ownership'
46import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
47import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils'
48import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
49import { videoCaptionsRouter } from './captions' 63import { videoCaptionsRouter } from './captions'
64import { videoCommentRouter } from './comment'
50import { videoImportsRouter } from './import' 65import { videoImportsRouter } from './import'
51import { resetSequelizeInstance } from '../../../helpers/database-utils' 66import { ownershipVideoRouter } from './ownership'
52import { move } from 'fs-extra' 67import { rateVideoRouter } from './rate'
53import { watchingRouter } from './watching' 68import { watchingRouter } from './watching'
54import { Notifier } from '../../../lib/notifier'
55import { sendView } from '../../../lib/activitypub/send/send-view'
56import { CONFIG } from '../../../initializers/config'
57import { sequelizeTypescript } from '../../../initializers/database'
58import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail'
59import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
60import { Hooks } from '../../../lib/plugins/hooks'
61import { MVideoDetails, MVideoFullLight } from '@server/types/models'
62import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
63import { getVideoFilePath } from '@server/lib/video-paths'
64import toInt from 'validator/lib/toInt'
65import { addOptimizeOrMergeAudioJob } from '@server/helpers/video'
66import { getServerActor } from '@server/models/application/application'
67import { changeVideoChannelShare } from '@server/lib/activitypub/share'
68import { getVideoActivityPubUrl } from '@server/lib/activitypub/url'
69 69
70const auditLogger = auditLoggerFactory('videos') 70const auditLogger = auditLoggerFactory('videos')
71const videosRouter = express.Router() 71const videosRouter = express.Router()
@@ -105,7 +105,7 @@ videosRouter.get('/privacies', listVideoPrivacies)
105videosRouter.get('/', 105videosRouter.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,