aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/requests.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/controllers/api/requests.js
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
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}