summaryrefslogtreecommitdiff
path: root/api.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-01-23 12:58:12 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-01-23 13:02:09 +0100
commit068035760ca3abd22b67d0b53bf73f2e83209b53 (patch)
tree86d4fcdeab7cc4f6f993c7fe04e496b2116f2149 /api.py
parentc121a662e16c5ff17bb8a0ed64875dd8a1a8f2b0 (diff)
downloadapigrabber-068035760ca3abd22b67d0b53bf73f2e83209b53.tar.gz
apigrabber-068035760ca3abd22b67d0b53bf73f2e83209b53.zip
api: send requests synchronously
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"))