aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/requests.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-11 21:50:51 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-19 21:22:28 +0100
commitfeb4bdfd9b46e87aadfa7c0d5338cde887d1f58c (patch)
tree2abc9fbc9569760e218fd52835850b757344b420 /server/controllers/api/requests.js
parent108626609eda75e4ecc0a83a650a4d53c46220e0 (diff)
downloadPeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.gz
PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.zst
PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.zip
First version with PostgreSQL
Diffstat (limited to 'server/controllers/api/requests.js')
-rw-r--r--server/controllers/api/requests.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/server/controllers/api/requests.js b/server/controllers/api/requests.js
index 52aad6997..1f9193fc8 100644
--- a/server/controllers/api/requests.js
+++ b/server/controllers/api/requests.js
@@ -1,15 +1,13 @@
1'use strict' 1'use strict'
2 2
3const express = require('express') 3const express = require('express')
4const mongoose = require('mongoose')
5 4
6const constants = require('../../initializers/constants') 5const constants = require('../../initializers/constants')
6const db = require('../../initializers/database')
7const middlewares = require('../../middlewares') 7const middlewares = require('../../middlewares')
8const admin = middlewares.admin 8const admin = middlewares.admin
9const oAuth = middlewares.oauth 9const oAuth = middlewares.oauth
10 10
11const Request = mongoose.model('Request')
12
13const router = express.Router() 11const router = express.Router()
14 12
15router.get('/stats', 13router.get('/stats',
@@ -25,13 +23,13 @@ module.exports = router
25// --------------------------------------------------------------------------- 23// ---------------------------------------------------------------------------
26 24
27function getStatsRequests (req, res, next) { 25function getStatsRequests (req, res, next) {
28 Request.list(function (err, requests) { 26 db.Request.countTotalRequests(function (err, totalRequests) {
29 if (err) return next(err) 27 if (err) return next(err)
30 28
31 return res.json({ 29 return res.json({
32 requests: requests, 30 totalRequests: totalRequests,
33 maxRequestsInParallel: constants.REQUESTS_IN_PARALLEL, 31 maxRequestsInParallel: constants.REQUESTS_IN_PARALLEL,
34 remainingMilliSeconds: Request.remainingMilliSeconds(), 32 remainingMilliSeconds: db.Request.remainingMilliSeconds(),
35 milliSecondsInterval: constants.REQUESTS_INTERVAL 33 milliSecondsInterval: constants.REQUESTS_INTERVAL
36 }) 34 })
37 }) 35 })