upsert_nutrition_day
Create or update daily nutrition entries to track food intake and dietary patterns within a fitness tracking system.
Instructions
Create or update a nutrition day entry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | ||
| notes | No |
Implementation Reference
- src/main.py:379-392 (handler)The handler for the 'upsert_nutrition_day' tool, which inserts or updates a nutrition day record in the database.
@app.tool() def upsert_nutrition_day(date: str, notes: Optional[str] = None) -> dict[str, int]: """Create or update a nutrition day entry.""" date = _ensure_date(date) conn = get_connection() cursor = conn.cursor() cursor.execute( "INSERT INTO nutrition_days (date, notes) VALUES (?, ?) ON CONFLICT(date) DO UPDATE SET notes = ?", (date, notes, notes), ) day_id = cursor.lastrowid or cursor.execute("SELECT id FROM nutrition_days WHERE date = ?", (date,)).fetchone()[0] conn.commit() conn.close() return {"day_id": day_id}