smart tdee
This commit is contained in:
@@ -7,7 +7,7 @@ from app.homelab.rss import RssClient
|
||||
def build_morning_digest(db: Session, *, include_news: bool = True) -> str:
|
||||
del db # timezone resolved via weather client / profile in future extensions
|
||||
weather_client = OpenMeteoClient()
|
||||
weather = weather_client.fetch_current_and_hourly(hours_ahead=12)
|
||||
weather = weather_client.fetch_forecast(hours_ahead=12, days_ahead=7)
|
||||
|
||||
lines = ["🌤 **Утренний дайджест**", ""]
|
||||
|
||||
@@ -18,7 +18,10 @@ def build_morning_digest(db: Session, *, include_news: bool = True) -> str:
|
||||
f"{cur.get('temperature_c')}°C, {cur.get('conditions')}, "
|
||||
f"ветер {cur.get('wind_speed_kmh')} км/ч."
|
||||
)
|
||||
lines.append(weather_client.rain_summary(hours_ahead=12))
|
||||
lines.append(weather_client.rain_summary(hours_ahead=12, daily=weather.get("daily")))
|
||||
daily = weather_client.daily_summary(days_ahead=7)
|
||||
if daily:
|
||||
lines.append(f"**На неделю**: {daily}")
|
||||
else:
|
||||
lines.append(f"**Погода**: недоступна ({weather.get('error', 'ошибка')}).")
|
||||
|
||||
@@ -41,12 +44,13 @@ def build_morning_digest(db: Session, *, include_news: bool = True) -> str:
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def build_weather_briefing(hours_ahead: int = 12, include_news: bool = False) -> dict:
|
||||
def build_weather_briefing(hours_ahead: int = 12, days_ahead: int = 7, include_news: bool = False) -> dict:
|
||||
client = OpenMeteoClient()
|
||||
weather = client.fetch_current_and_hourly(hours_ahead=hours_ahead)
|
||||
weather = client.fetch_forecast(hours_ahead=hours_ahead, days_ahead=days_ahead)
|
||||
result = {
|
||||
"weather": weather,
|
||||
"rain_summary": client.rain_summary(hours_ahead=hours_ahead) if weather.get("ok") else "",
|
||||
"rain_summary": client.rain_summary(hours_ahead=hours_ahead, daily=weather.get("daily")) if weather.get("ok") else "",
|
||||
"daily_summary": client.daily_summary(days_ahead=days_ahead) if weather.get("ok") else "",
|
||||
"context": format_weather_snapshot(weather),
|
||||
}
|
||||
if include_news:
|
||||
|
||||
Reference in New Issue
Block a user