From 9638fe930b4252d306389b5a27ce942614906db7 Mon Sep 17 00:00:00 2001 From: schneefux Date: Thu, 16 Feb 2017 18:11:00 +0100 Subject: fail on SQL errors --- api.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/api.py b/api.py index d42c2aa..c7ae8f7 100644 --- a/api.py +++ b/api.py @@ -57,13 +57,8 @@ class Processor(object): stop_after -= 1 # TODO for debugging, don't process whole table async with srccon.transaction(): async with destcon.transaction(): - rec_o = "" - try: - async for rec in srccon.cursor(query): - rec_o = rec - await self.into(destcon, rec, table) - except: - logging.error("rec: %s", rec_o) + async for rec in srccon.cursor(query): + await self.into(destcon, rec, table) async def into(self, conn, data, table): """Insert a named tuple into a table.""" @@ -72,11 +67,7 @@ class Processor(object): placeholders = ["${}".format(i) for i, _ in enumerate(values, 1)] query = "INSERT INTO {} (\"{}\") VALUES ({})".format( table, "\", \"".join(keys), ", ".join(placeholders)) - try: - await conn.execute(query, (*data)) - except: - logging.error("Query: '%s'", query) - logging.error("Data: '%s'", data) + await conn.execute(query, (*data)) async def main(): -- cgit v1.3.1 From cfb59a7772aad708120c953fad30e88986f82441 Mon Sep 17 00:00:00 2001 From: schneefux Date: Thu, 16 Feb 2017 18:11:25 +0100 Subject: workaround for participants not including some data --- queries/match_participation.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/queries/match_participation.sql b/queries/match_participation.sql index d37983f..43785c6 100644 --- a/queries/match_participation.sql +++ b/queries/match_participation.sql @@ -1,23 +1,23 @@ SELECT -id AS "participant_id", -relationships->'player'-> 'data' ->> 'id' AS player_id, +relationships->'player'->'data'->>'id' AS player_id, +0 AS "match_id", 0 AS "rosterId", 0 AS "fk_player_id", 0 AS "fk_match_results_id", attributes->>'actor' AS "hero", -(attributes->'stats'->>'kills')::int AS "kills", +COALESCE(NULLIF(attributes->'stats'->>'kills', ''), '0')::int AS "kills", (attributes->'stats'->>'deaths')::int AS "deaths", (attributes->'stats'->>'assists')::int AS "assists", 0.0 AS "KD", 0.0 AS "KDA", 0 AS "killParticipation", -(attributes->'stats'->>'nonJungleMinionKills')::int AS "laneMinionsSlayed", -(attributes->'stats'->>'minionKills')::int AS "jungleMinionsSlayed", -(attributes->'stats'->>'turretCaptures')::int AS "turretsDestroyed", -(attributes->'stats'->>'krakenCaptures')::int AS "krakenCaptures", -(attributes->'stats'->>'goldMineCaptures')::int AS "goldMineCaptures", -(attributes->'stats'->>'crystalMineCaptures')::int AS "crystalMineCaptures", +COALESCE(NULLIF(attributes->'stats'->>'nonJungleMinionKills', ''), '0')::int AS "laneMinionsSlayed", +COALESCE(NULLIF(attributes->'stats'->>'minionKills', ''), '0')::int AS "jungleMinionsSlayed", +COALESCE(NULLIF(attributes->'stats'->>'turretCaptures', ''), '0')::int AS "turretsDestroyed", +COALESCE(NULLIF(attributes->'stats'->>'krakenCaptures', ''), '0')::int AS "krakenCaptures", +COALESCE(NULLIF(attributes->'stats'->>'goldMineCaptures', ''), '0')::int AS "goldMineCaptures", +COALESCE(NULLIF(attributes->'stats'->>'crystalMineCaptures', ''), '0')::int AS "crystalMineCaptures", (attributes->'stats'->>'wentAfk')::bool::int AS "wentAfk", FALSE AS "perfectGame" -- cgit v1.3.1