summaryrefslogtreecommitdiff
path: root/generate-json.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-09-07 02:10:36 +0200
committeremkael <emkael@tlen.pl>2017-09-07 02:10:36 +0200
commit4060fa99c23bca17895029ae1ffad24d0d024269 (patch)
treecf4f322e236d913e238366a2de30727d0d2561cb /generate-json.py
parent26f2934bcdfec9b32131ec01bbdd493146b3ad57 (diff)
Moving *.py scripts to separate directory, cleaning things up
Diffstat (limited to 'generate-json.py')
-rw-r--r--generate-json.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/generate-json.py b/generate-json.py
deleted file mode 100644
index 54bb26d..0000000
--- a/generate-json.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import json, sys
-from pyranking.db import cursor
-
-date = sys.argv[1]
-
-sql = '''SELECT
- rankings.place,
- players.id,
- players.rank,
- rankings.score
-FROM players
-LEFT JOIN rankings
- ON players.id = rankings.pid
- AND rankings.date = %(date)s
-'''
-cursor.execute(sql, {'date': date})
-
-result = {}
-for row in cursor.fetchall():
- if row['place'] is not None:
- result[row['id']] = {
- 'place': int(row['place']),
- 'rank': float(row['rank']),
- 'score': float(row['score'])
- }
- else:
- result[row['id']] = {
- 'rank': float(row['rank'])
- }
-
-print json.dumps(result)