diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-10 17:27:49 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 571389d43b8fc8aaf27e77c06f19b320b08dbbc9 (patch) | |
tree | e57173bcd0590d939c28952a29258fd02a281e35 /server/controllers/api/request-schedulers.ts | |
parent | 38fa2065831b5f55be0d7f30f19a62c967397208 (diff) | |
download | PeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.tar.gz PeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.tar.zst PeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.zip |
Make it compile at least
Diffstat (limited to 'server/controllers/api/request-schedulers.ts')
-rw-r--r-- | server/controllers/api/request-schedulers.ts | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/server/controllers/api/request-schedulers.ts b/server/controllers/api/request-schedulers.ts deleted file mode 100644 index 4c8fbe18b..000000000 --- a/server/controllers/api/request-schedulers.ts +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | import * as express from 'express' | ||
2 | import * as Bluebird from 'bluebird' | ||
3 | |||
4 | import { | ||
5 | AbstractRequestScheduler, | ||
6 | getRequestScheduler, | ||
7 | getRequestVideoQaduScheduler, | ||
8 | getRequestVideoEventScheduler | ||
9 | } from '../../lib' | ||
10 | import { authenticate, ensureUserHasRight, asyncMiddleware } from '../../middlewares' | ||
11 | import { RequestSchedulerStatsAttributes, UserRight } from '../../../shared' | ||
12 | |||
13 | const requestSchedulerRouter = express.Router() | ||
14 | |||
15 | requestSchedulerRouter.get('/stats', | ||
16 | authenticate, | ||
17 | ensureUserHasRight(UserRight.MANAGE_REQUEST_SCHEDULERS), | ||
18 | asyncMiddleware(getRequestSchedulersStats) | ||
19 | ) | ||
20 | |||
21 | // --------------------------------------------------------------------------- | ||
22 | |||
23 | export { | ||
24 | requestSchedulerRouter | ||
25 | } | ||
26 | |||
27 | // --------------------------------------------------------------------------- | ||
28 | |||
29 | async function getRequestSchedulersStats (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
30 | const result = await Bluebird.props({ | ||
31 | requestScheduler: buildRequestSchedulerStats(getRequestScheduler()), | ||
32 | requestVideoQaduScheduler: buildRequestSchedulerStats(getRequestVideoQaduScheduler()), | ||
33 | requestVideoEventScheduler: buildRequestSchedulerStats(getRequestVideoEventScheduler()) | ||
34 | }) | ||
35 | |||
36 | return res.json(result) | ||
37 | } | ||
38 | |||
39 | // --------------------------------------------------------------------------- | ||
40 | |||
41 | async function buildRequestSchedulerStats (requestScheduler: AbstractRequestScheduler<any>) { | ||
42 | const count = await requestScheduler.remainingRequestsCount() | ||
43 | |||
44 | const result: RequestSchedulerStatsAttributes = { | ||
45 | totalRequests: count, | ||
46 | requestsLimitPods: requestScheduler.limitPods, | ||
47 | requestsLimitPerPod: requestScheduler.limitPerPod, | ||
48 | remainingMilliSeconds: requestScheduler.remainingMilliSeconds(), | ||
49 | milliSecondsInterval: requestScheduler.requestInterval | ||
50 | } | ||
51 | |||
52 | return result | ||
53 | } | ||