aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/requests.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/requests.js')
-rw-r--r--server/controllers/api/requests.js55
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
3const express = require('express')
4const parallel = require('async/parallel')
5
6const friends = require('../../lib/friends')
7const middlewares = require('../../middlewares')
8const admin = middlewares.admin
9const oAuth = middlewares.oauth
10
11const router = express.Router()
12
13router.get('/stats',
14 oAuth.authenticate,
15 admin.ensureIsAdmin,
16 getStatsRequests
17)
18
19// ---------------------------------------------------------------------------
20
21module.exports = router
22
23// ---------------------------------------------------------------------------
24
25function 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
39function 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}