diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-22 12:38:34 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-22 12:38:34 +0200 |
| commit | 5d9ad017725fa599c8424e424ecf7f11a08eb0ec (patch) | |
| tree | 0517d2388003457cff9185d0e1b634f771277269 | |
| parent | 1125651395fa2f6666ef8da04726f6a07919740f (diff) | |
| download | bridge-5d9ad017725fa599c8424e424ecf7f11a08eb0ec.tar.gz bridge-5d9ad017725fa599c8424e424ecf7f11a08eb0ec.zip | |
implement player upcrunchrelease/2.4.0
| -rw-r--r-- | server.js | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -299,14 +299,24 @@ async function updateSamples(region) { await setKey("samples_last_update", region, last_update); } -// wipe all points that meet the `where` condition and recrunch +// upcrunch player's stats async function crunchPlayer(api_id) { - logger.info("deleting all player points", { api_id: api_id }); - await model.PlayerPoint.destroy({ where: { player_api_id: api_id } }); + const last_crunch = await model.PlayerPoint.findOne({ + attributes: ["updated_at"], + where: { player_api_id: api_id }, + order: [ ["updated_at", "DESC"] ] + }), + last_crunch_date = last_crunch == undefined? + new Date(0) : last_crunch.updated_at; // get all participants for this player const participations = await model.Participant.findAll({ attributes: ["api_id"], - where: { player_api_id: api_id } }); + where: { + player_api_id: api_id, + created_at: { + $gt: last_crunch_date + } + } }); // send everything to cruncher logger.info("sending participations to cruncher", { length: participations.length }); |
