summaryrefslogtreecommitdiff
path: root/api.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-01-23 20:04:34 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-01-23 20:04:34 +0100
commit7082b09f7804553487c469630b526d239e7adf06 (patch)
treee287061ce8c940d611c1d53cd9b03ab202dcec1e /api.py
parent068035760ca3abd22b67d0b53bf73f2e83209b53 (diff)
downloadapigrabber-7082b09f7804553487c469630b526d239e7adf06.tar.gz
apigrabber-7082b09f7804553487c469630b526d239e7adf06.zip
api: fix getting new matches
Diffstat (limited to 'api.py')
-rw-r--r--api.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/api.py b/api.py
index 1686204..f5e1380 100644
--- a/api.py
+++ b/api.py
@@ -11,13 +11,16 @@ async def main():
await db.connect("postgres://vgstats@localhost/vgstats")
api = crawler.Crawler()
try:
- await db.meta("last_match_update")
+ last_match_update = await db.meta("last_match_update")
except KeyError:
- await db.meta("last_match_update",
- datetime.datetime(1, 1, 1).isoformat())
- matches = await api.matches_since(
- await db.meta("last_match_update"))
+ last_match_update = datetime.datetime(1, 1, 1).isoformat()
+ await db.meta("last_match_update", last_match_update)
+ print("getting new matches since " + last_match_update)
+ await db.meta("last_match_update", datetime.datetime.now().isoformat())
+ matches = await api.matches_since(last_match_update)
+ print("inserting data into database")
await db.upsert("na", matches, True)
+ print("calculating stats")
print(await db.select("SELECT data->'attributes'->>'name' as name FROM player WHERE CAST(data->'attributes'->'stats'->>'winStreak' AS integer) > 3"))
loop = asyncio.get_event_loop()