forked from odota/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processMmr.js
39 lines (39 loc) · 1.24 KB
/
processMmr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var utility = require('./utility');
var db = require('./db');
var logger = utility.logger;
var getData = utility.getData;
module.exports = function processMmr(job, cb) {
var payload = job.data.payload;
getData({
url: job.data.url,
noRetry: true
}, function(err, data) {
if (err) {
logger.info(err);
//don't clutter kue with failed mmr reqs
//if any error occurs (including retriever down) we simply skip getting MMR for this match
return cb(null, err);
}
logger.info("mmr response");
if (data.solo_competitive_rank || data.competitive_rank) {
db.players.update({
account_id: payload.account_id
}, {
$push: {
ratings: {
match_id: payload.match_id,
account_id: payload.account_id,
soloCompetitiveRank: data.solo_competitive_rank,
competitiveRank: data.competitive_rank,
time: new Date()
}
}
}, function(err) {
cb(err);
});
}
else {
cb(null);
}
});
}