aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/request.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-09-19 21:33:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-09-19 21:33:46 +0200
commitd3cd34be2fd03ea79145dfa8eb16e82d2e23191b (patch)
tree8db702444c4b72cec9de25efb2da5df0aa51cfce /server/models/request.js
parent2e92c10b6cdb32e5170aab0b4c0ff3e4c27e30d5 (diff)
downloadPeerTube-d3cd34be2fd03ea79145dfa8eb16e82d2e23191b.tar.gz
PeerTube-d3cd34be2fd03ea79145dfa8eb16e82d2e23191b.tar.zst
PeerTube-d3cd34be2fd03ea79145dfa8eb16e82d2e23191b.zip
Server: add requests stats endpoint
Diffstat (limited to 'server/models/request.js')
-rw-r--r--server/models/request.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/server/models/request.js b/server/models/request.js
index 4d521919a..4e510e18a 100644
--- a/server/models/request.js
+++ b/server/models/request.js
@@ -19,14 +19,15 @@ let timer = null
19 19
20const RequestSchema = mongoose.Schema({ 20const RequestSchema = mongoose.Schema({
21 request: mongoose.Schema.Types.Mixed, 21 request: mongoose.Schema.Types.Mixed,
22 to: [ { type: mongoose.Schema.Types.ObjectId, ref: 'users' } ] 22 to: [ { type: mongoose.Schema.Types.ObjectId, ref: 'Pod' } ]
23}) 23})
24 24
25RequestSchema.statics = { 25RequestSchema.statics = {
26 activate, 26 activate,
27 deactivate, 27 deactivate,
28 flush, 28 flush,
29 forceSend 29 forceSend,
30 list
30} 31}
31 32
32RequestSchema.pre('save', function (next) { 33RequestSchema.pre('save', function (next) {
@@ -53,7 +54,7 @@ mongoose.model('Request', RequestSchema)
53 54
54function activate () { 55function activate () {
55 logger.info('Requests scheduler activated.') 56 logger.info('Requests scheduler activated.')
56 timer = setInterval(makeRequests.bind(this), constants.INTERVAL) 57 timer = setInterval(makeRequests.bind(this), constants.REQUESTS_INTERVAL)
57} 58}
58 59
59function deactivate () { 60function deactivate () {
@@ -72,6 +73,10 @@ function forceSend () {
72 makeRequests.call(this) 73 makeRequests.call(this)
73} 74}
74 75
76function list (callback) {
77 this.find({ }, callback)
78}
79
75// --------------------------------------------------------------------------- 80// ---------------------------------------------------------------------------
76 81
77// Make a requests to friends of a certain type 82// Make a requests to friends of a certain type