From 8054669f1181e815c435e76e81247eff32d41dc5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 20 Aug 2020 09:19:21 +0200 Subject: Optimize default sort when listing videos createdAt does not have the appropriate index --- server/controllers/api/users/me.ts | 3 ++- server/controllers/api/users/my-subscriptions.ts | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'server/controllers/api/users') diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 914c52e27..ba60a3d2a 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -17,6 +17,7 @@ import { paginationValidator, setDefaultPagination, setDefaultSort, + setDefaultVideosSort, usersUpdateMeValidator, usersVideoRatingValidator } from '../../../middlewares' @@ -60,7 +61,7 @@ meRouter.get('/me/videos', authenticate, paginationValidator, videosSortValidator, - setDefaultSort, + setDefaultVideosSort, setDefaultPagination, asyncMiddleware(getUserVideos) ) diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 8b88feaf3..b8c234eef 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts @@ -1,7 +1,11 @@ -import * as express from 'express' import 'multer' +import * as express from 'express' +import { VideoFilter } from '../../../../shared/models/videos/video-query.type' +import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' import { getFormattedObjects } from '../../../helpers/utils' import { WEBSERVER } from '../../../initializers/constants' +import { sequelizeTypescript } from '../../../initializers/database' +import { JobQueue } from '../../../lib/job-queue' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -10,21 +14,18 @@ import { paginationValidator, setDefaultPagination, setDefaultSort, + setDefaultVideosSort, userSubscriptionAddValidator, userSubscriptionGetValidator } from '../../../middlewares' import { areSubscriptionsExistValidator, + userSubscriptionListValidator, userSubscriptionsSortValidator, - videosSortValidator, - userSubscriptionListValidator + videosSortValidator } from '../../../middlewares/validators' -import { VideoModel } from '../../../models/video/video' -import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' -import { VideoFilter } from '../../../../shared/models/videos/video-query.type' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { JobQueue } from '../../../lib/job-queue' -import { sequelizeTypescript } from '../../../initializers/database' +import { VideoModel } from '../../../models/video/video' const mySubscriptionsRouter = express.Router() @@ -32,7 +33,7 @@ mySubscriptionsRouter.get('/me/subscriptions/videos', authenticate, paginationValidator, videosSortValidator, - setDefaultSort, + setDefaultVideosSort, setDefaultPagination, commonVideosFiltersValidator, asyncMiddleware(getUserSubscriptionVideos) -- cgit v1.2.3