From 3241a657dceec0d88677d99d5264f09d8f1cfb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Thu, 4 Feb 2016 16:47:32 +0100 Subject: [PATCH] [Loudash migration] Fix Team stats --- app/coffee/modules/team/main.coffee | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/coffee/modules/team/main.coffee b/app/coffee/modules/team/main.coffee index 2dd37f04..7e5733b8 100644 --- a/app/coffee/modules/team/main.coffee +++ b/app/coffee/modules/team/main.coffee @@ -110,15 +110,18 @@ class TeamController extends mixOf(taiga.Controller, taiga.PageMixin) @scope.stats.totals = @scope.totals _processStat: (stat) -> - max = _.max(stat) - min = _.min(stat) - singleStat = _.map stat, (value, key) -> + max = _.max(_.toArray(stat)) + min = _.min(_.toArray(stat)) + + singleStat = Object() + for own key, value of stat if value == min - return [key, 0.1] - if value == max - return [key, 1] - return [key, (value * 0.5) / max] - singleStat = _.object(singleStat) + singleStat[key] = 0.1 + else if value == max + singleStat[key] = 1 + else + singleStat[key] = (value * 0.5) / max + return singleStat _processStats: (stats) ->