diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/index.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/request-schedulers.ts (renamed from server/controllers/api/requests.ts) | 22 |
2 files changed, 13 insertions, 13 deletions
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts index ac3972ac6..3abe9bcf8 100644 --- a/server/controllers/api/index.ts +++ b/server/controllers/api/index.ts | |||
@@ -6,7 +6,7 @@ import { clientsRouter } from './clients' | |||
6 | import { configRouter } from './config' | 6 | import { configRouter } from './config' |
7 | import { podsRouter } from './pods' | 7 | import { podsRouter } from './pods' |
8 | import { remoteRouter } from './remote' | 8 | import { remoteRouter } from './remote' |
9 | import { requestsRouter } from './requests' | 9 | import { requestSchedulerRouter } from './request-schedulers' |
10 | import { usersRouter } from './users' | 10 | import { usersRouter } from './users' |
11 | import { videosRouter } from './videos' | 11 | import { videosRouter } from './videos' |
12 | 12 | ||
@@ -16,7 +16,7 @@ apiRouter.use('/clients', clientsRouter) | |||
16 | apiRouter.use('/config', configRouter) | 16 | apiRouter.use('/config', configRouter) |
17 | apiRouter.use('/pods', podsRouter) | 17 | apiRouter.use('/pods', podsRouter) |
18 | apiRouter.use('/remote', remoteRouter) | 18 | apiRouter.use('/remote', remoteRouter) |
19 | apiRouter.use('/requests', requestsRouter) | 19 | apiRouter.use('/request-schedulers', requestSchedulerRouter) |
20 | apiRouter.use('/users', usersRouter) | 20 | apiRouter.use('/users', usersRouter) |
21 | apiRouter.use('/videos', videosRouter) | 21 | apiRouter.use('/videos', videosRouter) |
22 | apiRouter.use('/ping', pong) | 22 | apiRouter.use('/ping', pong) |
diff --git a/server/controllers/api/requests.ts b/server/controllers/api/request-schedulers.ts index 5718b59b7..8dd849007 100644 --- a/server/controllers/api/requests.ts +++ b/server/controllers/api/request-schedulers.ts | |||
@@ -8,29 +8,29 @@ import { | |||
8 | getRequestVideoEventScheduler | 8 | getRequestVideoEventScheduler |
9 | } from '../../lib' | 9 | } from '../../lib' |
10 | import { authenticate, ensureIsAdmin } from '../../middlewares' | 10 | import { authenticate, ensureIsAdmin } from '../../middlewares' |
11 | import { RequestSchedulerAttributes } from '../../../shared' | 11 | import { RequestSchedulerStatsAttributes } from '../../../shared' |
12 | 12 | ||
13 | const requestsRouter = express.Router() | 13 | const requestSchedulerRouter = express.Router() |
14 | 14 | ||
15 | requestsRouter.get('/stats', | 15 | requestSchedulerRouter.get('/stats', |
16 | authenticate, | 16 | authenticate, |
17 | ensureIsAdmin, | 17 | ensureIsAdmin, |
18 | getStatsRequests | 18 | getRequestSchedulersStats |
19 | ) | 19 | ) |
20 | 20 | ||
21 | // --------------------------------------------------------------------------- | 21 | // --------------------------------------------------------------------------- |
22 | 22 | ||
23 | export { | 23 | export { |
24 | requestsRouter | 24 | requestSchedulerRouter |
25 | } | 25 | } |
26 | 26 | ||
27 | // --------------------------------------------------------------------------- | 27 | // --------------------------------------------------------------------------- |
28 | 28 | ||
29 | function getStatsRequests (req: express.Request, res: express.Response, next: express.NextFunction) { | 29 | function getRequestSchedulersStats (req: express.Request, res: express.Response, next: express.NextFunction) { |
30 | parallel({ | 30 | parallel({ |
31 | requestScheduler: buildRequestSchedulerFunction(getRequestScheduler()), | 31 | requestScheduler: buildRequestSchedulerStats(getRequestScheduler()), |
32 | requestVideoQaduScheduler: buildRequestSchedulerFunction(getRequestVideoQaduScheduler()), | 32 | requestVideoQaduScheduler: buildRequestSchedulerStats(getRequestVideoQaduScheduler()), |
33 | requestVideoEventScheduler: buildRequestSchedulerFunction(getRequestVideoEventScheduler()) | 33 | requestVideoEventScheduler: buildRequestSchedulerStats(getRequestVideoEventScheduler()) |
34 | }, function (err, result) { | 34 | }, function (err, result) { |
35 | if (err) return next(err) | 35 | if (err) return next(err) |
36 | 36 | ||
@@ -40,12 +40,12 @@ function getStatsRequests (req: express.Request, res: express.Response, next: ex | |||
40 | 40 | ||
41 | // --------------------------------------------------------------------------- | 41 | // --------------------------------------------------------------------------- |
42 | 42 | ||
43 | function buildRequestSchedulerFunction (requestScheduler: AbstractRequestScheduler) { | 43 | function buildRequestSchedulerStats (requestScheduler: AbstractRequestScheduler) { |
44 | return function (callback) { | 44 | return function (callback) { |
45 | requestScheduler.remainingRequestsCount(function (err, count) { | 45 | requestScheduler.remainingRequestsCount(function (err, count) { |
46 | if (err) return callback(err) | 46 | if (err) return callback(err) |
47 | 47 | ||
48 | const result: RequestSchedulerAttributes = { | 48 | const result: RequestSchedulerStatsAttributes = { |
49 | totalRequests: count, | 49 | totalRequests: count, |
50 | requestsLimitPods: requestScheduler.limitPods, | 50 | requestsLimitPods: requestScheduler.limitPods, |
51 | requestsLimitPerPod: requestScheduler.limitPerPod, | 51 | requestsLimitPerPod: requestScheduler.limitPerPod, |