fixed reminder
This commit is contained in:
@@ -48,7 +48,7 @@ def format_fitness_context(snapshot: dict[str, Any]) -> str:
|
||||
|
||||
lines.append("")
|
||||
lines.append(
|
||||
"Правила: log_meal, log_water, log_weight, log_workout, get_fitness_summary, "
|
||||
"Правила: log_meal, log_water, log_weight, log_workout, get_fitness_summary (date/days_ago), get_fitness_history, "
|
||||
"set_fitness_profile, calc_fitness_targets, lookup_food, lookup_exercise. "
|
||||
"Еда — оценка LLM (≈), пользователь может уточнить."
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import json
|
||||
from datetime import date, datetime, time, timezone
|
||||
from datetime import date, datetime, time, timedelta, timezone
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import func, select
|
||||
@@ -346,10 +346,46 @@ class FitnessService:
|
||||
def calc_one_rm(self, weight_kg: float, reps: int) -> dict[str, Any]:
|
||||
return {"ok": True, "one_rm_kg": one_rep_max(weight_kg, reps)}
|
||||
|
||||
def get_history(
|
||||
self,
|
||||
*,
|
||||
days: int = 7,
|
||||
end_day: date | None = None,
|
||||
) -> dict[str, Any]:
|
||||
days = max(1, min(days, 90))
|
||||
end = end_day or datetime.now(timezone.utc).date()
|
||||
start = end - timedelta(days=days - 1)
|
||||
summaries: list[dict[str, Any]] = []
|
||||
|
||||
for offset in range(days):
|
||||
d = start + timedelta(days=offset)
|
||||
full = self.get_daily_summary(d)
|
||||
totals = full["totals"]
|
||||
has_data = bool(full["meals"] or full["water"] or full["workouts"])
|
||||
summaries.append(
|
||||
{
|
||||
"date": full["date"],
|
||||
"has_data": has_data,
|
||||
"totals": totals,
|
||||
"targets": full["targets"],
|
||||
"meal_count": len(full["meals"]),
|
||||
"workout_count": len(full["workouts"]),
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
"start_date": start.isoformat(),
|
||||
"end_date": end.isoformat(),
|
||||
"days": days,
|
||||
"summaries": summaries,
|
||||
}
|
||||
|
||||
def snapshot(self) -> dict[str, Any]:
|
||||
today = datetime.now(timezone.utc).date()
|
||||
return {
|
||||
"profile": self.get_profile(),
|
||||
"today": self.get_daily_summary(),
|
||||
"today": self.get_daily_summary(today),
|
||||
"history": self.get_history(days=7, end_day=today),
|
||||
"body_metrics": self.list_body_metrics(limit=10),
|
||||
"reminders": self.list_reminders(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user