From e3ab900cef5228045d398360652b7dfd79847d82 Mon Sep 17 00:00:00 2001 From: Stefan Pleiner Date: Tue, 27 Aug 2024 18:24:31 +0200 Subject: [PATCH] Use cache ttl instead of custom timestamp --- slussen.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/slussen.py b/slussen.py index 920f04d..f1220bc 100644 --- a/slussen.py +++ b/slussen.py @@ -1,5 +1,3 @@ -import time - import requests import streamlit as st @@ -24,7 +22,7 @@ @st.cache_data -def get_departures(timestamp): +def get_departures(ttl=60): departures = [] for site in sites: url = f"https://transport.integration.sl.se/v1/sites/{site}/departures?transport=BUS" @@ -104,7 +102,7 @@ def get_departures(timestamp): @st.cache_data -def get_deviations(timestamp): +def get_deviations(ttl=60): deviations = [] sitestring = "" for site in sites: @@ -133,9 +131,8 @@ def get_deviations(timestamp): return deviations -timestamp = time.strftime("%Y%m%d%H%M") -departuredata = get_departures(timestamp) -deviationdata = get_deviations(timestamp) +departuredata = get_departures() +deviationdata = get_deviations() if deviationdata: with st.expander("**:red[Trafikstörningar]**", icon="🚨"):