diff options
Diffstat (limited to 'server/controllers/api/requests.js')
-rw-r--r-- | server/controllers/api/requests.js | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/server/controllers/api/requests.js b/server/controllers/api/requests.js deleted file mode 100644 index 6fd5753ac..000000000 --- a/server/controllers/api/requests.js +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const express = require('express') | ||
4 | const parallel = require('async/parallel') | ||
5 | |||
6 | const friends = require('../../lib/friends') | ||
7 | const middlewares = require('../../middlewares') | ||
8 | const admin = middlewares.admin | ||
9 | const oAuth = middlewares.oauth | ||
10 | |||
11 | const router = express.Router() | ||
12 | |||
13 | router.get('/stats', | ||
14 | oAuth.authenticate, | ||
15 | admin.ensureIsAdmin, | ||
16 | getStatsRequests | ||
17 | ) | ||
18 | |||
19 | // --------------------------------------------------------------------------- | ||
20 | |||
21 | module.exports = router | ||
22 | |||
23 | // --------------------------------------------------------------------------- | ||
24 | |||
25 | function getStatsRequests (req, res, next) { | ||
26 | parallel({ | ||
27 | requestScheduler: buildRequestSchedulerFunction(friends.getRequestScheduler()), | ||
28 | requestVideoQaduScheduler: buildRequestSchedulerFunction(friends.getRequestVideoQaduScheduler()), | ||
29 | requestVideoEventScheduler: buildRequestSchedulerFunction(friends.getRequestVideoEventScheduler()) | ||
30 | }, function (err, result) { | ||
31 | if (err) return next(err) | ||
32 | |||
33 | return res.json(result) | ||
34 | }) | ||
35 | } | ||
36 | |||
37 | // --------------------------------------------------------------------------- | ||
38 | |||
39 | function buildRequestSchedulerFunction (requestScheduler) { | ||
40 | return function (callback) { | ||
41 | requestScheduler.remainingRequestsCount(function (err, count) { | ||
42 | if (err) return callback(err) | ||
43 | |||
44 | const result = { | ||
45 | totalRequests: count, | ||
46 | requestsLimitPods: requestScheduler.limitPods, | ||
47 | requestsLimitPerPod: requestScheduler.limitPerPod, | ||
48 | remainingMilliSeconds: requestScheduler.remainingMilliSeconds(), | ||
49 | milliSecondsInterval: requestScheduler.requestInterval | ||
50 | } | ||
51 | |||
52 | return callback(null, result) | ||
53 | }) | ||
54 | } | ||
55 | } | ||