Add scheduled weather sentinel, admin weather location API and UI#74
Add scheduled weather sentinel, admin weather location API and UI#74DivyanshuChipa wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6fa3b6518
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
|
|
||
|
|
||
| def _get_default_coordinates() -> tuple[float, float]: |
There was a problem hiding this comment.
Avoid Python 3.9-only tuple annotation in backend task
This repository declares Python 3.8+ support, but tuple[float, float] requires Python 3.9+ (unless postponed evaluation is enabled). On Python 3.8, importing this module raises TypeError: 'type' object is not subscriptable, which prevents server.py from importing tasks.py and can stop the backend from starting at all.
Useful? React with 👍 / 👎.
| for username in list(connected_clients.keys()): | ||
| await send_to_user(username, payload_json) |
There was a problem hiding this comment.
Mark weather alerts delivered after websocket send
This path creates delivery_status rows for all recipients, but the websocket send loop does not mark recipients as delivered when send_to_user succeeds. In this codebase, pending rows are replayed on reconnect via get_undelivered_messages, so users who already received the live weather alert will get a duplicate after reconnecting.
Useful? React with 👍 / 👎.
Motivation
Description
backend/tasks.pyimplementingrun_proactive_weather_sentinelwhich fetches forecasts from Open-Meteo, uses the AI engine (ask_ai) to generate a short warning, saves/broadcasts the message, and creates delivery entries.get_default_locationandset_default_locationtobackend/users.pyto store default coordinates in theconfigtable.GET /admin/weather_locationandPOST /admin/weather_locationinbackend/admin_api.pyand wired the new user helpers into imports.AsyncIOSchedulerin the FastAPIlifespan(inbackend/server.py) that schedulesrun_proactive_weather_sentinelto run daily at 07:00 IST and shuts down cleanly.intra_admin/admin.pywith a weather location card,load_weather_locationandsave_weather_locationto call the new endpoints and validate input.backend/requirements.txtto includeapschedulerandhttpx(and addedhttpxusage intasks.py).Testing
Codex Task