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/accounts.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/accounts.ts')
-rw-r--r-- | server/controllers/api/accounts.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index b1c05c6c0..0a73dfcbf 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts | |||
@@ -1,5 +1,8 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getServerActor } from '@server/models/application/application' | ||
3 | import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | ||
2 | import { getFormattedObjects } from '../../helpers/utils' | 4 | import { getFormattedObjects } from '../../helpers/utils' |
5 | import { JobQueue } from '../../lib/job-queue' | ||
3 | import { | 6 | import { |
4 | asyncMiddleware, | 7 | asyncMiddleware, |
5 | authenticate, | 8 | authenticate, |
@@ -8,6 +11,7 @@ import { | |||
8 | paginationValidator, | 11 | paginationValidator, |
9 | setDefaultPagination, | 12 | setDefaultPagination, |
10 | setDefaultSort, | 13 | setDefaultSort, |
14 | setDefaultVideosSort, | ||
11 | videoPlaylistsSortValidator, | 15 | videoPlaylistsSortValidator, |
12 | videoRatesSortValidator, | 16 | videoRatesSortValidator, |
13 | videoRatingValidator | 17 | videoRatingValidator |
@@ -17,18 +21,15 @@ import { | |||
17 | accountsSortValidator, | 21 | accountsSortValidator, |
18 | ensureAuthUserOwnsAccountValidator, | 22 | ensureAuthUserOwnsAccountValidator, |
19 | videoChannelsSortValidator, | 23 | videoChannelsSortValidator, |
20 | videosSortValidator, | 24 | videoChannelStatsValidator, |
21 | videoChannelStatsValidator | 25 | videosSortValidator |
22 | } from '../../middlewares/validators' | 26 | } from '../../middlewares/validators' |
27 | import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists' | ||
23 | import { AccountModel } from '../../models/account/account' | 28 | import { AccountModel } from '../../models/account/account' |
24 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' | 29 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' |
25 | import { VideoModel } from '../../models/video/video' | 30 | import { VideoModel } from '../../models/video/video' |
26 | import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | ||
27 | import { VideoChannelModel } from '../../models/video/video-channel' | 31 | import { VideoChannelModel } from '../../models/video/video-channel' |
28 | import { JobQueue } from '../../lib/job-queue' | ||
29 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 32 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
30 | import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists' | ||
31 | import { getServerActor } from '@server/models/application/application' | ||
32 | 33 | ||
33 | const accountsRouter = express.Router() | 34 | const accountsRouter = express.Router() |
34 | 35 | ||
@@ -49,7 +50,7 @@ accountsRouter.get('/:accountName/videos', | |||
49 | asyncMiddleware(accountNameWithHostGetValidator), | 50 | asyncMiddleware(accountNameWithHostGetValidator), |
50 | paginationValidator, | 51 | paginationValidator, |
51 | videosSortValidator, | 52 | videosSortValidator, |
52 | setDefaultSort, | 53 | setDefaultVideosSort, |
53 | setDefaultPagination, | 54 | setDefaultPagination, |
54 | optionalAuthenticate, | 55 | optionalAuthenticate, |
55 | commonVideosFiltersValidator, | 56 | commonVideosFiltersValidator, |