mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
docs: update documentation for new features and recent changes
- Remove references to deprecated bot commands (/pajares, /sanisidro, /fuentes, /all) - Document new /suscribir and /desuscribir subscription commands - Add push notification system description and usage - Document admin accuracy reports with environment variable setup - Add sky_condition and snow_type fields to API spec and database schema - Update scheduled task description (training day changed from Monday to Sunday) - Add notification_subscribers table to schema - Update DEPLOYMENT.md with ADMIN_TELEGRAM_IDS environment variable - Mark completed milestones in TODO.md
This commit is contained in:
1 parent
2e40eee95a
commit
b4453917dc
5 files changed
+137
-4
No files matched your search
+105
@@ -41,6 +41,7 @@ This creates a venv, installs dependencies, downloads historical data, trains mo
|
||||
source .venv/bin/activate
|
||||
export TELEGRAM_BOT_TOKEN='your_token'
|
||||
export JWT_SECRET_KEY='your_secret'
|
||||
export ADMIN_TELEGRAM_IDS='123456789,987654321' # Optional: comma-separated admin user IDs
|
||||
uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||
```
|
||||
|
||||
@@ -89,3 +90,107 @@ export TELEGRAM_BOT_TOKEN='your_token'
|
||||
1. Check if the bot is active via `GET /api/v1/status`.
|
||||
2. Ensure `TELEGRAM_BOT_TOKEN` is correctly exported in the environment.
|
||||
3. Check uvicorn logs for bot startup errors.
|
||||
|
||||
## Telegram Bot Commands
|
||||
|
||||
### User Commands
|
||||
- `/start` — Welcome message with brief description
|
||||
- `/help` — List all available commands
|
||||
- `/hoy` — All three stations' forecast for today
|
||||
- `/manana` — All three stations' forecast for tomorrow
|
||||
- `/tresdias` — All three stations' forecasts for next 3 days
|
||||
- `/semana` — All three stations' forecasts for next 7 days
|
||||
- `/suscribir` — Subscribe to daily 20:00 push notifications (tomorrow's forecast)
|
||||
- `/desuscribir` — Unsubscribe from push notifications
|
||||
|
||||
### Push Notifications System
|
||||
|
||||
Users who execute `/suscribir` receive automated daily predictions via push notification at 20:00 Madrid time.
|
||||
|
||||
**How it works:**
|
||||
1. User sends `/suscribir` → subscriber entry created in `notification_subscribers` table
|
||||
2. At 20:00 daily, the extended task broadcasts tomorrow's forecast to all active subscribers
|
||||
3. If a user blocks the bot (Telegram API returns "Forbidden"), their subscription is automatically deactivated
|
||||
|
||||
**Database table:**
|
||||
```
|
||||
notification_subscribers:
|
||||
- telegram_chat_id (UNIQUE)
|
||||
- telegram_username (optional)
|
||||
- subscribed_at (ISO timestamp)
|
||||
- active (0 or 1)
|
||||
```
|
||||
|
||||
## Admin Accuracy Reports
|
||||
|
||||
When `ADMIN_TELEGRAM_IDS` environment variable is set, the system sends daily accuracy reports to designated admins at 20:00.
|
||||
|
||||
**How it works:**
|
||||
1. Extract yesterday's 20:00 prediction for today from `past_forecasts`
|
||||
2. Compare against today's actual station data in `historical_actuals`
|
||||
3. Compute divergence metrics:
|
||||
- `open_status_match`: Did prediction match actual open/closed?
|
||||
- `open_prob_error`: |predicted_probability - actual_status|
|
||||
- `km_error`: |predicted_km - actual_km|
|
||||
- `km_error_pct`: percentage error for km
|
||||
4. Compute 30-day accumulated accuracy
|
||||
5. Format report in Spanish with station breakdowns
|
||||
6. Send via Telegram to each admin ID
|
||||
|
||||
**Report includes:**
|
||||
- Per-station accuracy with match status (✅/❌)
|
||||
- km prediction error
|
||||
- Daily summary (% open accuracy, avg km error)
|
||||
- 30-day accumulated statistics
|
||||
|
||||
**Setup:**
|
||||
```bash
|
||||
export ADMIN_TELEGRAM_IDS='123456789,987654321'
|
||||
```
|
||||
|
||||
## Weather Data Enhancements
|
||||
|
||||
### New Forecast Fields
|
||||
|
||||
All forecasts now include two new fields:
|
||||
|
||||
- **`sky_condition`**: Derived from WMO weather code, values: `"soleado"`, `"parcialmente nublado"`, `"nublado"`, `"niebla"`, `"nublado con nieve"`, `"tormenta"`, `"desconocido"`
|
||||
- **`snow_type`**: Inferred from temperature + snowfall or from Infonieve historical data, values: `"polvo"`, `"húmeda"`, `"dura"`, `"primavera"`, `"artificial"`, `"costra"`, `"desconocido"`
|
||||
|
||||
These fields appear in:
|
||||
- REST API responses (forecast endpoints)
|
||||
- Telegram bot messages (displayed as "Cielo:" and "Tipo de nieve:")
|
||||
- SQLite `current_forecasts` and `past_forecasts` tables
|
||||
|
||||
### Data Source
|
||||
|
||||
- **Weather codes** come from Open-Meteo (WMO standard codes)
|
||||
- **Snow type** primarily from Infonieve's `calidadnieve` column when available; otherwise inferred from temperature and snowfall conditions
|
||||
|
||||
## Database Schema Updates
|
||||
|
||||
### New Table: `notification_subscribers`
|
||||
```sql
|
||||
CREATE TABLE notification_subscribers (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
telegram_chat_id INTEGER UNIQUE NOT NULL,
|
||||
telegram_username TEXT,
|
||||
subscribed_at TEXT NOT NULL,
|
||||
active INTEGER DEFAULT 1
|
||||
);
|
||||
```
|
||||
|
||||
### Updated Tables: `current_forecasts`, `past_forecasts`
|
||||
|
||||
New columns added:
|
||||
- `sky_condition TEXT` — Sky condition label
|
||||
- `snow_type TEXT` — Snow type/quality label
|
||||
- `weather_code INTEGER` — WMO weather code (raw)
|
||||
|
||||
Example query to inspect new fields:
|
||||
```bash
|
||||
sqlite3 data/processed/skipredictor.db \
|
||||
"SELECT station_id, prediction_date, open_probability, sky_condition, snow_type
|
||||
FROM current_forecasts
|
||||
ORDER BY station_id, prediction_date;"
|
||||
```
|
||||
Reference in new issue
Block a user