e
This commit is contained in:
parent
a979f0bf75
commit
00000d97a5
8 changed files with 40 additions and 29 deletions
|
|
@ -37,7 +37,7 @@ TAG = "STRMSG8"
|
|||
def get_event(t1: str, t2: str) -> str:
|
||||
match t1:
|
||||
case "RED ZONE":
|
||||
return "Red Zone"
|
||||
return "NFL RedZone"
|
||||
|
||||
case "TBD":
|
||||
return "TBD"
|
||||
|
|
@ -58,7 +58,9 @@ async def get_api_data(client: httpx.AsyncClient, url: str) -> list[dict[str, An
|
|||
return r.json()
|
||||
|
||||
|
||||
async def refresh_api_cache(client: httpx.AsyncClient) -> list[dict[str, Any]]:
|
||||
async def refresh_api_cache(
|
||||
client: httpx.AsyncClient, ts: float
|
||||
) -> list[dict[str, Any]]:
|
||||
log.info("Refreshing API cache")
|
||||
|
||||
tasks = [
|
||||
|
|
@ -73,7 +75,7 @@ async def refresh_api_cache(client: httpx.AsyncClient) -> list[dict[str, Any]]:
|
|||
for ev in data:
|
||||
ev["ts"] = ev.pop("timestamp")
|
||||
|
||||
data[-1]["timestamp"] = Time.now().timestamp()
|
||||
data[-1]["timestamp"] = ts
|
||||
|
||||
return data
|
||||
|
||||
|
|
@ -81,14 +83,15 @@ async def refresh_api_cache(client: httpx.AsyncClient) -> list[dict[str, Any]]:
|
|||
async def get_events(
|
||||
client: httpx.AsyncClient, cached_keys: set[str]
|
||||
) -> list[dict[str, str]]:
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
if not (api_data := API_FILE.load(per_entry=False, index=-1)):
|
||||
api_data = await refresh_api_cache(client)
|
||||
api_data = await refresh_api_cache(client, now.timestamp())
|
||||
|
||||
API_FILE.write(api_data)
|
||||
|
||||
events = []
|
||||
|
||||
now = Time.clean(Time.now())
|
||||
start_dt = now.delta(minutes=-30)
|
||||
end_dt = now.delta(minutes=30)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue