From b7e442270e0427c8ebf0d246edd91c26d1ad37a1 Mon Sep 17 00:00:00 2001
From: kvahuja <k.v.ahuja@gmail.com>
Date: Fri, 17 Feb 2017 21:08:14 +0530
Subject: match and roster tables refactored

---
 queries/match.sql | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

(limited to 'queries/match.sql')

diff --git a/queries/match.sql b/queries/match.sql
index 0ff0c62..8ee527a 100644
--- a/queries/match.sql
+++ b/queries/match.sql
@@ -1,18 +1,12 @@
 SELECT
 
-id AS "match_id",
+id AS "apiId",
+(attributes->>'createdAt')::timestamp as "createdAt",
 (attributes->>'duration')::int AS "duration",
 attributes->>'gameMode' AS "gameMode",
-COALESCE(NULLIF(attributes->>'patchVersion', ''), '0')::int AS "patchVersion",
-attributes->>'shardId' AS "shard",
-attributes->'stats'->>'endGameReason' AS "result",
-attributes->'stats'->>'queue' AS "queue",
-
-false AS "anyAFK",
-'' AS "winningTeam",
-0 AS "krakenCaptures",
-0 AS "laneMinionsSlayed",
-0 AS "jungleMinionsSlayed",
-0 AS "heroDeaths"
+COALESCE(NULLIF(attributes->>'patchVersion', ''), '0') AS "patchVersion",
+attributes->>'shardId' AS "shardId",
+attributes->'stats'->>'endGameReason' AS "endGameReason",
+attributes->'stats'->>'queue' AS "queue"
 
 FROM match
-- 
cgit v1.3.1


From fd0c4e67b13ee0d90b579a3d2279ff7a815725c2 Mon Sep 17 00:00:00 2001
From: kvahuja <k.v.ahuja@gmail.com>
Date: Sun, 19 Feb 2017 13:11:26 +0530
Subject: match to roster relationship

---
 queries/match.sql | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

(limited to 'queries/match.sql')

diff --git a/queries/match.sql b/queries/match.sql
index 8ee527a..4f82933 100644
--- a/queries/match.sql
+++ b/queries/match.sql
@@ -7,6 +7,9 @@ attributes->>'gameMode' AS "gameMode",
 COALESCE(NULLIF(attributes->>'patchVersion', ''), '0') AS "patchVersion",
 attributes->>'shardId' AS "shardId",
 attributes->'stats'->>'endGameReason' AS "endGameReason",
-attributes->'stats'->>'queue' AS "queue"
+attributes->'stats'->>'queue' AS "queue",
+
+relationships->'rosters'->'data'->0->>'id' as roster_1,
+relationships->'rosters'->'data'->1->>'id' as roster_2
 
 FROM match
-- 
cgit v1.3.1

