diff options
Diffstat (limited to 'server/controllers/api/overviews.ts')
-rw-r--r-- | server/controllers/api/overviews.ts | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts index ad879aad6..2dfac15ef 100644 --- a/server/controllers/api/overviews.ts +++ b/server/controllers/api/overviews.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as memoizee from 'memoizee' | ||
3 | import { logger } from '@server/helpers/logger' | ||
4 | import { Hooks } from '@server/lib/plugins/hooks' | ||
5 | import { VideoModel } from '@server/models/video/video' | ||
6 | import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' | ||
2 | import { buildNSFWFilter } from '../../helpers/express-utils' | 7 | import { buildNSFWFilter } from '../../helpers/express-utils' |
3 | import { VideoModel } from '../../models/video/video' | 8 | import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' |
4 | import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' | 9 | import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' |
5 | import { TagModel } from '../../models/video/tag' | 10 | import { TagModel } from '../../models/video/tag' |
6 | import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' | ||
7 | import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' | ||
8 | import * as memoizee from 'memoizee' | ||
9 | import { logger } from '@server/helpers/logger' | ||
10 | 11 | ||
11 | const overviewsRouter = express.Router() | 12 | const overviewsRouter = express.Router() |
12 | 13 | ||
@@ -108,7 +109,7 @@ async function getVideos ( | |||
108 | res: express.Response, | 109 | res: express.Response, |
109 | where: { videoChannelId?: number, tagsOneOf?: string[], categoryOneOf?: number[] } | 110 | where: { videoChannelId?: number, tagsOneOf?: string[], categoryOneOf?: number[] } |
110 | ) { | 111 | ) { |
111 | const query = Object.assign({ | 112 | const query = await Hooks.wrapObject({ |
112 | start: 0, | 113 | start: 0, |
113 | count: 12, | 114 | count: 12, |
114 | sort: '-createdAt', | 115 | sort: '-createdAt', |
@@ -116,10 +117,16 @@ async function getVideos ( | |||
116 | nsfw: buildNSFWFilter(res), | 117 | nsfw: buildNSFWFilter(res), |
117 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, | 118 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, |
118 | withFiles: false, | 119 | withFiles: false, |
119 | countVideos: false | 120 | countVideos: false, |
120 | }, where) | 121 | |
122 | ...where | ||
123 | }, 'filter:api.overviews.videos.list.params') | ||
121 | 124 | ||
122 | const { data } = await VideoModel.listForApi(query) | 125 | const { data } = await Hooks.wrapPromiseFun( |
126 | VideoModel.listForApi, | ||
127 | query, | ||
128 | 'filter:api.overviews.videos.list.result' | ||
129 | ) | ||
123 | 130 | ||
124 | return data.map(d => d.toFormattedJSON()) | 131 | return data.map(d => d.toFormattedJSON()) |
125 | } | 132 | } |