2024-01-05 22:30:58 -05:00
|
|
|
"""
|
2024-01-05 23:42:44 -05:00
|
|
|
WordGuess Leaderboard Viewer
|
2024-01-05 22:30:58 -05:00
|
|
|
Author: Brandon Rozek
|
|
|
|
"""
|
2024-01-05 23:42:44 -05:00
|
|
|
from datetime import datetime
|
|
|
|
import argparse
|
|
|
|
import sqlite3
|
2024-01-05 22:30:58 -05:00
|
|
|
|
|
|
|
from wordguess import WordGuess
|
|
|
|
|
2024-01-05 23:42:44 -05:00
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(description="Leaderboard for WordGuess Game")
|
|
|
|
parser.add_argument("--date", type=str, help="Filter scores by date listed in YYYY-MM-DD format.")
|
|
|
|
args = vars(parser.parse_args())
|
2024-01-05 22:30:58 -05:00
|
|
|
|
2024-01-05 23:42:44 -05:00
|
|
|
# If not specified, then use today's date
|
|
|
|
DATE = args.get("date", str(datetime.today().date()))
|
2024-01-05 22:30:58 -05:00
|
|
|
|
|
|
|
con = sqlite3.connect(WordGuess.RESULTS_LOCATION)
|
|
|
|
try:
|
|
|
|
cur = con.cursor()
|
|
|
|
res = cur.execute(f"SELECT user, score FROM scores WHERE date = '{DATE}' ORDER BY score DESC")
|
|
|
|
for username, score in res.fetchall():
|
|
|
|
print(username, score)
|
|
|
|
finally:
|
|
|
|
con.close()
|