diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-08-23 19:45:16 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-08-23 19:45:16 +0200 |
| commit | 618d149e36936e07007755aca532691547f4b503 (patch) | |
| tree | 46b1049a8422ef3b92597eb15dfc457dff9e09e6 | |
| parent | 3eb8a03ee43c24a3254f1f2e705855dac5c92722 (diff) | |
| download | bridge-618d149e36936e07007755aca532691547f4b503.tar.gz bridge-618d149e36936e07007755aca532691547f4b503.zip | |
add crunch_pending notification for players
| -rw-r--r-- | service_crunch.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/service_crunch.js b/service_crunch.js index c9597e9..22c0170 100644 --- a/service_crunch.js +++ b/service_crunch.js @@ -63,14 +63,15 @@ module.exports = class Cruncher extends Service { } logger.info("player in db, crunching", { name: req.params.name }); players.forEach((player) => - this.crunchPlayer(category, player.api_id)); // fire away + this.crunchPlayer(category, player.api_id, player.name)); + // fire away res.sendStatus(204); } }); } // upcrunch player's stats - async crunchPlayer(category, api_id) { + async crunchPlayer(category, api_id, name) { const db = this.getDatabase(category), where = { player_api_id: api_id }, last_crunch_r = await db.PlayerPoint.findOne({ @@ -90,9 +91,16 @@ module.exports = class Cruncher extends Service { // send everything to cruncher logger.info("sending participations to cruncher", { length: participations.length }); - await Promise.map(participations, async (p) => + await Promise.map(participations, async (p) => { + await this.notify("player." + name, "crunch_pending"); + await this.forward(this.getTarget(category + "_player"), - p.api_id, { persistent: true })); + p.api_id, { + persistent: true, + headers: { notify: "player." + player.name } + } + ); + }); } // crunch global stats |
