diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-15 22:22:03 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-20 09:57:40 +0200 |
commit | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch) | |
tree | 4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/controllers/api/requests.js | |
parent | d5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff) | |
download | PeerTube-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.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 | } | ||