Skip to content

Add scheduled weather sentinel, admin weather location API and UI#74

Open
DivyanshuChipa wants to merge 1 commit intomasterfrom
codex/implement-proactive-weather-sentinel-xkufba
Open

Add scheduled weather sentinel, admin weather location API and UI#74
DivyanshuChipa wants to merge 1 commit intomasterfrom
codex/implement-proactive-weather-sentinel-xkufba

Conversation

@DivyanshuChipa
Copy link
Copy Markdown
Owner

Motivation

  • Add a proactive weather sentinel to notify connected users (Family Group) about heavy rain or extreme heat.
  • Allow admins to configure a default weather location used by the sentinel.
  • Run the sentinel on a daily schedule within the FastAPI app lifecycle.

Description

  • Introduced backend/tasks.py implementing run_proactive_weather_sentinel which fetches forecasts from Open-Meteo, uses the AI engine (ask_ai) to generate a short warning, saves/broadcasts the message, and creates delivery entries.
  • Added persistent config helpers get_default_location and set_default_location to backend/users.py to store default coordinates in the config table.
  • Added admin API endpoints GET /admin/weather_location and POST /admin/weather_location in backend/admin_api.py and wired the new user helpers into imports.
  • Started an AsyncIOScheduler in the FastAPI lifespan (in backend/server.py) that schedules run_proactive_weather_sentinel to run daily at 07:00 IST and shuts down cleanly.
  • Added GUI support in intra_admin/admin.py with a weather location card, load_weather_location and save_weather_location to call the new endpoints and validate input.
  • Updated backend/requirements.txt to include apscheduler and httpx (and added httpx usage in tasks.py).

Testing

  • No automated tests were executed as part of this change.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +51 to +52
for username in list(connected_clients.keys()):
await send_to_user(username, payload_json)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant