aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/accounts.ts7
-rw-r--r--server/middlewares/validators/videos/video-channels.ts14
-rw-r--r--server/models/video/video-channel.ts1
3 files changed, 17 insertions, 5 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index f354ccf24..f8d2bad8b 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -17,7 +17,8 @@ import {
17 accountsSortValidator, 17 accountsSortValidator,
18 ensureAuthUserOwnsAccountValidator, 18 ensureAuthUserOwnsAccountValidator,
19 videoChannelsSortValidator, 19 videoChannelsSortValidator,
20 videosSortValidator 20 videosSortValidator,
21 videoChannelStatsValidator
21} from '../../middlewares/validators' 22} from '../../middlewares/validators'
22import { AccountModel } from '../../models/account/account' 23import { AccountModel } from '../../models/account/account'
23import { AccountVideoRateModel } from '../../models/account/account-video-rate' 24import { AccountVideoRateModel } from '../../models/account/account-video-rate'
@@ -56,6 +57,7 @@ accountsRouter.get('/:accountName/videos',
56 57
57accountsRouter.get('/:accountName/video-channels', 58accountsRouter.get('/:accountName/video-channels',
58 asyncMiddleware(accountNameWithHostGetValidator), 59 asyncMiddleware(accountNameWithHostGetValidator),
60 videoChannelStatsValidator,
59 paginationValidator, 61 paginationValidator,
60 videoChannelsSortValidator, 62 videoChannelsSortValidator,
61 setDefaultSort, 63 setDefaultSort,
@@ -116,7 +118,8 @@ async function listAccountChannels (req: express.Request, res: express.Response)
116 accountId: res.locals.account.id, 118 accountId: res.locals.account.id,
117 start: req.query.start, 119 start: req.query.start,
118 count: req.query.count, 120 count: req.query.count,
119 sort: req.query.sort 121 sort: req.query.sort,
122 withStats: req.query.withStats
120 } 123 }
121 124
122 const resultList = await VideoChannelModel.listByAccount(options) 125 const resultList = await VideoChannelModel.listByAccount(options)
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index ebce14714..882fb2b84 100644
--- a/server/middlewares/validators/videos/video-channels.ts
+++ b/server/middlewares/validators/videos/video-channels.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { UserRight } from '../../../../shared' 3import { UserRight } from '../../../../shared'
4import { 4import {
5 isVideoChannelDescriptionValid, 5 isVideoChannelDescriptionValid,
@@ -128,6 +128,15 @@ const localVideoChannelValidator = [
128 } 128 }
129] 129]
130 130
131const videoChannelStatsValidator = [
132 query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'),
133
134 (req: express.Request, res: express.Response, next: express.NextFunction) => {
135 if (areValidationErrors(req, res)) return
136 return next()
137 }
138]
139
131// --------------------------------------------------------------------------- 140// ---------------------------------------------------------------------------
132 141
133export { 142export {
@@ -135,7 +144,8 @@ export {
135 videoChannelsUpdateValidator, 144 videoChannelsUpdateValidator,
136 videoChannelsRemoveValidator, 145 videoChannelsRemoveValidator,
137 videoChannelsNameWithHostValidator, 146 videoChannelsNameWithHostValidator,
138 localVideoChannelValidator 147 localVideoChannelValidator,
148 videoChannelStatsValidator
139} 149}
140 150
141// --------------------------------------------------------------------------- 151// ---------------------------------------------------------------------------
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 128915af3..5e6541837 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -412,7 +412,6 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
412 412
413 const scopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR ] 413 const scopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR ]
414 414
415 options.withStats = true // TODO: remove beyond after initial tests
416 if (options.withStats) { 415 if (options.withStats) {
417 scopes.push({ 416 scopes.push({
418 method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ] 417 method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ]