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/video-channel.ts | |
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/video-channel.ts')
-rw-r--r-- | server/controllers/api/video-channel.ts | 41 |
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getServerActor } from '@server/models/application/application' | ||
3 | import { MChannelAccountDefault } from '@server/types/models' | ||
4 | import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' | ||
5 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' | ||
6 | import { resetSequelizeInstance } from '../../helpers/database-utils' | ||
7 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | ||
8 | import { logger } from '../../helpers/logger' | ||
2 | import { getFormattedObjects } from '../../helpers/utils' | 9 | import { getFormattedObjects } from '../../helpers/utils' |
10 | import { CONFIG } from '../../initializers/config' | ||
11 | import { MIMETYPES } from '../../initializers/constants' | ||
12 | import { sequelizeTypescript } from '../../initializers/database' | ||
13 | import { setAsyncActorKeys } from '../../lib/activitypub/actor' | ||
14 | import { sendUpdateActor } from '../../lib/activitypub/send' | ||
15 | import { updateActorAvatarFile } from '../../lib/avatar' | ||
16 | import { JobQueue } from '../../lib/job-queue' | ||
17 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' | ||
3 | import { | 18 | import { |
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' |
18 | import { VideoChannelModel } from '../../models/video/video-channel' | 34 | import { videoChannelsNameWithHostValidator, videoChannelsOwnSearchValidator, videosSortValidator } from '../../middlewares/validators' |
19 | import { videoChannelsNameWithHostValidator, videosSortValidator, videoChannelsOwnSearchValidator } from '../../middlewares/validators' | 35 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' |
20 | import { sendUpdateActor } from '../../lib/activitypub/send' | 36 | import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' |
21 | import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' | ||
22 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' | ||
23 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | ||
24 | import { setAsyncActorKeys } from '../../lib/activitypub/actor' | ||
25 | import { AccountModel } from '../../models/account/account' | 37 | import { AccountModel } from '../../models/account/account' |
26 | import { MIMETYPES } from '../../initializers/constants' | ||
27 | import { logger } from '../../helpers/logger' | ||
28 | import { VideoModel } from '../../models/video/video' | 38 | import { VideoModel } from '../../models/video/video' |
29 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' | 39 | import { VideoChannelModel } from '../../models/video/video-channel' |
30 | import { updateActorAvatarFile } from '../../lib/avatar' | ||
31 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' | ||
32 | import { resetSequelizeInstance } from '../../helpers/database-utils' | ||
33 | import { JobQueue } from '../../lib/job-queue' | ||
34 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 40 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
35 | import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' | ||
36 | import { CONFIG } from '../../initializers/config' | ||
37 | import { sequelizeTypescript } from '../../initializers/database' | ||
38 | import { MChannelAccountDefault } from '@server/types/models' | ||
39 | import { getServerActor } from '@server/models/application/application' | ||
40 | 41 | ||
41 | const auditLogger = auditLoggerFactory('channels') | 42 | const auditLogger = auditLoggerFactory('channels') |
42 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 43 | const 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, |