summaryrefslogtreecommitdiff
path: root/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'api.py')
-rw-r--r--api.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/api.py b/api.py
index c679df9..1686204 100644
--- a/api.py
+++ b/api.py
@@ -3,13 +3,20 @@
import asyncio
import database
import crawler
+import datetime
async def main():
db = database.Database()
await db.connect("postgres://vgstats@localhost/vgstats")
api = crawler.Crawler()
- matches = await api.matches()
+ try:
+ 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"))
await db.upsert("na", matches, True)
print(await db.select("SELECT data->'attributes'->>'name' as name FROM player WHERE CAST(data->'attributes'->'stats'->>'winStreak' AS integer) > 3"))