From 9932435c28a82164a02f3039b46dd5fb98d5223a Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 7 Apr 2017 21:34:31 +0200 Subject: link items to participant --- worker.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'worker.js') diff --git a/worker.js b/worker.js index 84203ec..0c407eb 100644 --- a/worker.js +++ b/worker.js @@ -105,11 +105,16 @@ var RABBITMQ_URI = process.env.RABBITMQ_URI || "amqp://localhost", await model.Participant.findOne({ where: { api_id: api_participant.api_id }, include: [ { - model: model.Roster, - include: [ - model.Match - ] - } ] + model: model.Roster, + include: [ + model.Match + ] + }, { + model: model.ItemParticipant, + as: "items", + include: [ model.Item ] + } + ] }) )) })) @@ -166,6 +171,14 @@ var RABBITMQ_URI = process.env.RABBITMQ_URI || "amqp://localhost", if (participant.roster.get("hero_kills") == 0) participant_stats.kill_participation = 0; else participant_stats.kill_participation = participant.get("kills") / participant.roster.get("hero_kills"); + participant_stats.sustain_score = participant.items.reduce((score, item) => { + if (item.get("action") == "final") { + if (["Eve of Harvest", "Serpent Mask"].indexOf(item.item.get("name")) != -1) + return score + 20; + } + return score; + }, 0); + return participant_stats; } })(); -- cgit v1.3.1