From 3217e01dfd8b6649706b6872b2d2e20dd7cbff2c Mon Sep 17 00:00:00 2001
From: Kapil Viren Ahuja <k.v.ahuja@gmail.com>
Date: Tue, 25 Jul 2017 09:18:54 +0530
Subject: Fixed such that TS, TS_MU and TS_Sigma as stores as absolute values
 not sum. Shutter to review

---
 crunch_player.sql | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'crunch_player.sql')

diff --git a/crunch_player.sql b/crunch_player.sql
index 75432e8..bfb1574 100644
--- a/crunch_player.sql
+++ b/crunch_player.sql
@@ -9,15 +9,16 @@ select
     gm.id as game_mode_id,
     r.id as role_id,
 
+
     -- everything added here needs to be in on DUPLICATE too!!!
     count(p.id) as played,
     sum(cast(p.winner as INT)) as wins,
     sum(p_s.duration) as time_spent,
 
     -- special player_point facts
-    max(p.trueskill) as trueskill,
-    sum(p.trueskill_mu) as trueskill_mu,
-    sum(p.trueskill_sigma) as trueskill_sigma,
+    (p.trueskill_mu - p.trueskill_sigma) as trueskill,
+    p.trueskill_mu as trueskill_mu,
+    p.trueskill_sigma as trueskill_sigma,
     0 as elo,
 
     sum(p_s.kills) as kills,
@@ -52,8 +53,8 @@ played = played + values(played),
 wins = wins + values(wins),
 time_spent = time_spent + values(time_spent),
 trueskill = case when values(trueskill) > trueskill then values(trueskill) else trueskill end,
-trueskill_mu = trueskill_mu + values(trueskill_mu),
-trueskill_sigma = trueskill_sigma + values(trueskill_sigma),
+trueskill_mu =  case when values(trueskill_mu) > trueskill_mu then values(trueskill_mu) else trueskill_mu end,
+trueskill_sigma = case when values(trueskill_sigma) > trueskill_sigma then values(trueskill_sigma) else trueskill_sigma end,
 elo = elo + values(elo),
 kills = kills + values(kills),
 deaths = deaths + values(deaths),
-- 
cgit v1.3.1

