From e636eb88101a51399057c86477af6677f5614d48 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 25 Jun 2017 17:19:46 +0200 Subject: Requests -> RequestSchedulers --- server/controllers/api/requests.ts | 59 -------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 server/controllers/api/requests.ts (limited to 'server/controllers/api/requests.ts') diff --git a/server/controllers/api/requests.ts b/server/controllers/api/requests.ts deleted file mode 100644 index 5718b59b7..000000000 --- a/server/controllers/api/requests.ts +++ /dev/null @@ -1,59 +0,0 @@ -import * as express from 'express' -import { parallel } from 'async' - -import { - AbstractRequestScheduler, - getRequestScheduler, - getRequestVideoQaduScheduler, - getRequestVideoEventScheduler -} from '../../lib' -import { authenticate, ensureIsAdmin } from '../../middlewares' -import { RequestSchedulerAttributes } from '../../../shared' - -const requestsRouter = express.Router() - -requestsRouter.get('/stats', - authenticate, - ensureIsAdmin, - getStatsRequests -) - -// --------------------------------------------------------------------------- - -export { - requestsRouter -} - -// --------------------------------------------------------------------------- - -function getStatsRequests (req: express.Request, res: express.Response, next: express.NextFunction) { - parallel({ - requestScheduler: buildRequestSchedulerFunction(getRequestScheduler()), - requestVideoQaduScheduler: buildRequestSchedulerFunction(getRequestVideoQaduScheduler()), - requestVideoEventScheduler: buildRequestSchedulerFunction(getRequestVideoEventScheduler()) - }, function (err, result) { - if (err) return next(err) - - return res.json(result) - }) -} - -// --------------------------------------------------------------------------- - -function buildRequestSchedulerFunction (requestScheduler: AbstractRequestScheduler) { - return function (callback) { - requestScheduler.remainingRequestsCount(function (err, count) { - if (err) return callback(err) - - const result: RequestSchedulerAttributes = { - totalRequests: count, - requestsLimitPods: requestScheduler.limitPods, - requestsLimitPerPod: requestScheduler.limitPerPod, - remainingMilliSeconds: requestScheduler.remainingMilliSeconds(), - milliSecondsInterval: requestScheduler.requestInterval - } - - return callback(null, result) - }) - } -} -- cgit v1.2.3