aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/video-channel.ts
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/video-channel.ts
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/video-channel.ts')
-rw-r--r--server/controllers/api/video-channel.ts41
1 files changed, 21 insertions, 20 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index f705034fd..45c936978 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -1,5 +1,20 @@
1import * as express from 'express' 1import * as express from 'express'
2import { getServerActor } from '@server/models/application/application'
3import { MChannelAccountDefault } from '@server/types/models'
4import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared'
5import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
6import { resetSequelizeInstance } from '../../helpers/database-utils'
7import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
8import { logger } from '../../helpers/logger'
2import { getFormattedObjects } from '../../helpers/utils' 9import { getFormattedObjects } from '../../helpers/utils'
10import { CONFIG } from '../../initializers/config'
11import { MIMETYPES } from '../../initializers/constants'
12import { sequelizeTypescript } from '../../initializers/database'
13import { setAsyncActorKeys } from '../../lib/activitypub/actor'
14import { sendUpdateActor } from '../../lib/activitypub/send'
15import { updateActorAvatarFile } from '../../lib/avatar'
16import { JobQueue } from '../../lib/job-queue'
17import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'
3import { 18import {
4 asyncMiddleware, 19 asyncMiddleware,
5 asyncRetryTransactionMiddleware, 20 asyncRetryTransactionMiddleware,
@@ -9,34 +24,20 @@ import {
9 paginationValidator, 24 paginationValidator,
10 setDefaultPagination, 25 setDefaultPagination,
11 setDefaultSort, 26 setDefaultSort,
27 setDefaultVideosSort,
12 videoChannelsAddValidator, 28 videoChannelsAddValidator,
13 videoChannelsRemoveValidator, 29 videoChannelsRemoveValidator,
14 videoChannelsSortValidator, 30 videoChannelsSortValidator,
15 videoChannelsUpdateValidator, 31 videoChannelsUpdateValidator,
16 videoPlaylistsSortValidator 32 videoPlaylistsSortValidator
17} from '../../middlewares' 33} from '../../middlewares'
18import { VideoChannelModel } from '../../models/video/video-channel' 34import { videoChannelsNameWithHostValidator, videoChannelsOwnSearchValidator, videosSortValidator } from '../../middlewares/validators'
19import { videoChannelsNameWithHostValidator, videosSortValidator, videoChannelsOwnSearchValidator } from '../../middlewares/validators' 35import { updateAvatarValidator } from '../../middlewares/validators/avatar'
20import { sendUpdateActor } from '../../lib/activitypub/send' 36import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
21import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared'
22import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'
23import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
24import { setAsyncActorKeys } from '../../lib/activitypub/actor'
25import { AccountModel } from '../../models/account/account' 37import { AccountModel } from '../../models/account/account'
26import { MIMETYPES } from '../../initializers/constants'
27import { logger } from '../../helpers/logger'
28import { VideoModel } from '../../models/video/video' 38import { VideoModel } from '../../models/video/video'
29import { updateAvatarValidator } from '../../middlewares/validators/avatar' 39import { VideoChannelModel } from '../../models/video/video-channel'
30import { updateActorAvatarFile } from '../../lib/avatar'
31import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
32import { resetSequelizeInstance } from '../../helpers/database-utils'
33import { JobQueue } from '../../lib/job-queue'
34import { VideoPlaylistModel } from '../../models/video/video-playlist' 40import { VideoPlaylistModel } from '../../models/video/video-playlist'
35import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
36import { CONFIG } from '../../initializers/config'
37import { sequelizeTypescript } from '../../initializers/database'
38import { MChannelAccountDefault } from '@server/types/models'
39import { getServerActor } from '@server/models/application/application'
40 41
41const auditLogger = auditLoggerFactory('channels') 42const auditLogger = auditLoggerFactory('channels')
42const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 43const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
@@ -98,7 +99,7 @@ videoChannelRouter.get('/:nameWithHost/videos',
98 asyncMiddleware(videoChannelsNameWithHostValidator), 99 asyncMiddleware(videoChannelsNameWithHostValidator),
99 paginationValidator, 100 paginationValidator,
100 videosSortValidator, 101 videosSortValidator,
101 setDefaultSort, 102 setDefaultVideosSort,
102 setDefaultPagination, 103 setDefaultPagination,
103 optionalAuthenticate, 104 optionalAuthenticate,
104 commonVideosFiltersValidator, 105 commonVideosFiltersValidator,