ensure historical tables show full length
This commit is contained in:
@@ -57,13 +57,17 @@ class WordleDay:
|
|||||||
|
|
||||||
# Designed so that "today" will be the current date in CST
|
# Designed so that "today" will be the current date in CST
|
||||||
# Regardless of where the code is run
|
# Regardless of where the code is run
|
||||||
def get_wordle_today():
|
def get_today_central():
|
||||||
today = (
|
today = (
|
||||||
datetime.datetime.now(datetime.timezone.utc)
|
datetime.datetime.now(datetime.timezone.utc)
|
||||||
.astimezone(datetime.timezone(datetime.timedelta(hours=-5), name="US Central"))
|
.astimezone(datetime.timezone(datetime.timedelta(hours=-5), name="US Central"))
|
||||||
.date()
|
.date()
|
||||||
)
|
)
|
||||||
return WordleDay.from_date(today)
|
return today
|
||||||
|
|
||||||
|
|
||||||
|
def get_wordle_today():
|
||||||
|
return WordleDay.from_date(get_today_central())
|
||||||
|
|
||||||
|
|
||||||
WORDLE_TODAY = get_wordle_today()
|
WORDLE_TODAY = get_wordle_today()
|
||||||
|
|||||||
@@ -65,6 +65,16 @@ def wordle_today():
|
|||||||
return _wordle_today(get_ttl_hash())
|
return _wordle_today(get_ttl_hash())
|
||||||
|
|
||||||
|
|
||||||
|
def round_wordle_day(round_id):
|
||||||
|
wt = wordle_today()
|
||||||
|
rounds = games_from_db()
|
||||||
|
|
||||||
|
matching_round = [r for r in rounds if r.game_id == round_id][0]
|
||||||
|
if matching_round.game == wt.golf_hole.game_no:
|
||||||
|
return wt
|
||||||
|
return wordlinator.utils.WordleDay.from_date(matching_round.end_date)
|
||||||
|
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=3)
|
@functools.lru_cache(maxsize=3)
|
||||||
def _scores_from_db(round_id, ttl_hash=None):
|
def _scores_from_db(round_id, ttl_hash=None):
|
||||||
wordle_db = db.WordleDb()
|
wordle_db = db.WordleDb()
|
||||||
@@ -106,11 +116,12 @@ def get_leaderboard(round_id):
|
|||||||
|
|
||||||
def get_scores(round_id):
|
def get_scores(round_id):
|
||||||
score_matrix = scores_from_db(round_id)
|
score_matrix = scores_from_db(round_id)
|
||||||
table_rows = score_matrix.user_rows(wordle_today())
|
round_day = round_wordle_day(round_id)
|
||||||
|
table_rows = score_matrix.user_rows(round_day)
|
||||||
|
|
||||||
hole_columns = [
|
hole_columns = [
|
||||||
{"name": f"{i}", "id": f"{i}", "type": "text", "presentation": "markdown"}
|
{"name": f"{i}", "id": f"{i}", "type": "text", "presentation": "markdown"}
|
||||||
for i in range(1, wordle_today().golf_hole.hole_no + 1)
|
for i in range(1, round_day.golf_hole.hole_no + 1)
|
||||||
]
|
]
|
||||||
columns = [
|
columns = [
|
||||||
{"name": "Name", "id": "Name", "type": "text"},
|
{"name": "Name", "id": "Name", "type": "text"},
|
||||||
@@ -191,7 +202,10 @@ def get_daily_stats(round_id):
|
|||||||
{"name": n, "id": n}
|
{"name": n, "id": n}
|
||||||
for n in (
|
for n in (
|
||||||
"Score",
|
"Score",
|
||||||
*[f"{i}" for i in range(1, wordle_today().golf_hole.hole_no + 1)],
|
*[
|
||||||
|
f"{i}"
|
||||||
|
for i in range(1, round_wordle_day(round_id).golf_hole.hole_no + 1)
|
||||||
|
],
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
return dash.dash_table.DataTable(
|
return dash.dash_table.DataTable(
|
||||||
|
|||||||
Reference in New Issue
Block a user