refresh wordle day in cache

This commit is contained in:
2022-06-05 14:02:53 -05:00
parent 912a7aa6ae
commit aa00260c17
2 changed files with 23 additions and 12 deletions

View File

@@ -46,9 +46,13 @@ 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
today = ( def get_wordle_today():
datetime.datetime.now(datetime.timezone.utc) today = (
.astimezone(datetime.timezone(datetime.timedelta(hours=-5), name="US Central")) datetime.datetime.now(datetime.timezone.utc)
.date() .astimezone(datetime.timezone(datetime.timedelta(hours=-5), name="US Central"))
) .date()
WORDLE_TODAY = WordleDay.from_date(today) )
return WordleDay.from_date(today)
WORDLE_TODAY = get_wordle_today()

View File

@@ -27,9 +27,19 @@ long_callback_manager = dash.long_callback.DiskcacheLongCallbackManager(
) )
@functools.lru_cache()
def _wordle_today(ttl_hash=None):
return wordlinator.utils.get_wordle_today()
def wordle_today():
return _wordle_today(get_ttl_hash())
@functools.lru_cache() @functools.lru_cache()
def _scores_from_db(ttl_hash=None): def _scores_from_db(ttl_hash=None):
return db.WordleDb().get_scores(wordlinator.utils.WORDLE_TODAY.golf_hole.game_no) wordle_day = wordle_today()
return db.WordleDb().get_scores(wordle_day.golf_hole.game_no)
def scores_from_db(): def scores_from_db():
@@ -107,7 +117,7 @@ def get_scores():
hole_columns = [ hole_columns = [
{"name": f"Hole {i}", "id": f"Hole {i}", "type": "numeric"} {"name": f"Hole {i}", "id": f"Hole {i}", "type": "numeric"}
for i in range(1, wordlinator.utils.WORDLE_TODAY.golf_hole.hole_no + 1) for i in range(1, wordle_today().golf_hole.hole_no + 1)
] ]
columns = [ columns = [
{"name": "Name", "id": "Name", "type": "text"}, {"name": "Name", "id": "Name", "type": "text"},
@@ -202,10 +212,7 @@ def get_daily_stats():
{"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, wordlinator.utils.WORDLE_TODAY.golf_hole.hole_no + 1)
],
) )
] ]
return dash.dash_table.DataTable( return dash.dash_table.DataTable(