Skip to content

Commit

Permalink
Use cache ttl instead of custom timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
spleiner committed Aug 27, 2024
1 parent 544b038 commit e3ab900
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions slussen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import time

import requests
import streamlit as st

Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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="🚨"):
Expand Down

0 comments on commit e3ab900

Please sign in to comment.