summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-08-11 10:40:17 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2017-08-11 10:40:17 +0200
commitc899f8d0e23e73be6830a07ec90f70a3288bdb89 (patch)
tree6880a4a573537ece337dfa61fde52e3f76df6557
parentbd406fab310831604f1fbce494ef0510c33cca1e (diff)
downloadbridge-c899f8d0e23e73be6830a07ec90f70a3288bdb89.tar.gz
bridge-c899f8d0e23e73be6830a07ec90f70a3288bdb89.zip
don't wipe pp
-rw-r--r--service_analyze.js28
-rw-r--r--service_crunch.js4
2 files changed, 23 insertions, 9 deletions
diff --git a/service_analyze.js b/service_analyze.js
index 8e6ace8..c713b86 100644
--- a/service_analyze.js
+++ b/service_analyze.js
@@ -8,6 +8,7 @@ const Promise = require("bluebird"),
const logger = global.logger,
ANALYZE_QUEUE = process.env.ANALYZE_QUEUE || "analyze",
ANALYZE_TOURNAMENT_QUEUE = process.env.ANALYZE_TOURNAMENT_QUEUE || "analyze_tournament",
+ ANALYZE_MODES = (process.env.ANALYZE_MODES || "casual,ranked").split(","),
SHOVEL_SIZE = parseInt(process.env.SHOVEL_SIZE) || 1000;
module.exports = class Analyzer extends Service {
@@ -25,6 +26,11 @@ module.exports = class Analyzer extends Service {
this.analyzeGlobal(req.params.category || "regular");
res.sendStatus(204);
},
+ // calculate TrueSkill for everyone, overwriting everything
+ "/api/rerank/:category*?": async (req, res) => {
+ this.analyzeGlobal(req.params.category || "regular", true);
+ res.sendStatus(204);
+ },
// calculate TrueSkill for one player
"/api/player/:name/rank/:category*?": async (req, res) => {
const category = req.params.category || "regular",
@@ -43,21 +49,30 @@ module.exports = class Analyzer extends Service {
});
}
- async analyzeGlobal(category) {
+ // overwrite: analyze *all* matches
+ async analyzeGlobal(category, overwrite=false) {
const db = this.getDatabase(category);
- let offset = 0, matches;
+ let offset = new Date(0), matches;
do {
matches = await db.Match.findAll({
- attributes: ["api_id"],
- where: { trueskill_quality: null },
+ attributes: [ "api_id", "created_at" ],
+ where: overwrite? {
+ "created_at": { $gt: offset },
+ "game_mode": { $in: ANALYZE_MODES }
+ } : {
+ trueskill_quality: null,
+ "created_at": { $gt: offset },
+ "game_mode": { $in: ANALYZE_MODES }
+ },
limit: SHOVEL_SIZE,
- offset: offset,
order: [ ["created_at", "ASC"] ]
});
+ if (matches.length > 0)
+ offset = matches[matches.length-1].created_at;
+
await Promise.each(matches, async (m) =>
await this.forward(this.getTarget(category), m.api_id,
{ persistent: true }));
- offset += SHOVEL_SIZE;
logger.info("loading more matches into analyzer",
{ offset: offset, limit: SHOVEL_SIZE, size: matches.length });
} while (matches.length == SHOVEL_SIZE);
@@ -69,6 +84,7 @@ module.exports = class Analyzer extends Service {
participations = await db.Participant.findAll({
attributes: ["match_api_id"],
where: {
+ // TODO filter for ANALYZE_MODES
player_api_id: api_id,
trueskill_mu: null // where not analyzed yet
},
diff --git a/service_crunch.js b/service_crunch.js
index bc067ff..1ea6447 100644
--- a/service_crunch.js
+++ b/service_crunch.js
@@ -62,11 +62,9 @@ module.exports = class Cruncher extends Service {
});
if (last_crunch_r) where.created_at = { $gt: last_crunch_r.updated_at };
- // wipe previous calculations
- await db.PlayerPoint.destroy({ where });
// get all participants for this player
const participations = await db.Participant.findAll({
- attributes: [ "api_id" ],
+ attributes: [ "api_id", "created_at" ],
where,
order: [ ["created_at", "ASC" ] ]
});