diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-09-19 21:33:46 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-09-19 21:33:46 +0200 |
commit | d3cd34be2fd03ea79145dfa8eb16e82d2e23191b (patch) | |
tree | 8db702444c4b72cec9de25efb2da5df0aa51cfce /server/models/request.js | |
parent | 2e92c10b6cdb32e5170aab0b4c0ff3e4c27e30d5 (diff) | |
download | PeerTube-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.js | 11 |
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 | ||
20 | const RequestSchema = mongoose.Schema({ | 20 | const 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 | ||
25 | RequestSchema.statics = { | 25 | RequestSchema.statics = { |
26 | activate, | 26 | activate, |
27 | deactivate, | 27 | deactivate, |
28 | flush, | 28 | flush, |
29 | forceSend | 29 | forceSend, |
30 | list | ||
30 | } | 31 | } |
31 | 32 | ||
32 | RequestSchema.pre('save', function (next) { | 33 | RequestSchema.pre('save', function (next) { |
@@ -53,7 +54,7 @@ mongoose.model('Request', RequestSchema) | |||
53 | 54 | ||
54 | function activate () { | 55 | function 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 | ||
59 | function deactivate () { | 60 | function deactivate () { |
@@ -72,6 +73,10 @@ function forceSend () { | |||
72 | makeRequests.call(this) | 73 | makeRequests.call(this) |
73 | } | 74 | } |
74 | 75 | ||
76 | function 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 |