Limit weather API calls to cron only, increase cache TTL to 24h
Web view was calling the OpenWeatherMap API directly on every request (home + all trip locations), causing >1000 calls/day. Now web_view.py uses cache_only=True everywhere so it never triggers live API calls — update.py (cron) is the sole API caller. Also warms home location cache in update_weather(), and increases TTL from 6h to 24h. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
04cb3e8179
commit
feaefba03c
3 changed files with 45 additions and 6 deletions
|
|
@ -627,6 +627,7 @@ def get_home_weather() -> list[StrDict]:
|
|||
app.config.get("OPENWEATHERMAP_API_KEY", ""),
|
||||
app.config["HOME_LATITUDE"],
|
||||
app.config["HOME_LONGITUDE"],
|
||||
cache_only=True,
|
||||
)
|
||||
for f in forecasts:
|
||||
f["date_obj"] = date_type.fromisoformat(f["date"])
|
||||
|
|
@ -729,6 +730,7 @@ def trip_future_list() -> str:
|
|||
app.config["DATA_DIR"],
|
||||
app.config.get("OPENWEATHERMAP_API_KEY", ""),
|
||||
trip,
|
||||
cache_only=True,
|
||||
)
|
||||
for trip in shown
|
||||
}
|
||||
|
|
@ -1049,6 +1051,7 @@ def trip_page(start: str) -> str:
|
|||
app.config["DATA_DIR"],
|
||||
app.config.get("OPENWEATHERMAP_API_KEY", ""),
|
||||
trip,
|
||||
cache_only=True,
|
||||
)
|
||||
|
||||
return flask.render_template(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue