Spaces:
Running on Zero
Running on Zero
Commit History
28 days ago
-
fix: await the timezone lookup, and copy Postgres data across environments
The timezone fix in 2cdaf35 was broken and the regression test could not catch it. `user_today()` called the async `_tz_for()` without awaiting it, so pytz.timezone() received a coroutine, raised, and the code silently fell back to the machine timezone -- exactly the bug it was supposed to fix. The test passed because it asserted the fallback result. `user_today()` is now async and every caller awaits it, and the test sets two different timezones for the same frozen instant so a fallback can no longer satisfy it. Also add scripts/copy_postgres.py for the actual data migration. The bot's history lived in SQLite, was migrated to a local Postgres, and Supabase only ever received the schema -- so the production bot started from an empty database. The copy is additive (ON CONFLICT DO NOTHING never updates or deletes), offsets primary keys because local ids overlapped Supabase's (1..26 vs 21..22, 1..160 vs 1..14) and ON CONFLICT would otherwise silently drop rows, and never overwrites a use…7d3a67d
29 days ago
-
fix: unblock the HF Space build and make "today" follow the user timezone
Build - Hugging Face's Gradio SDK builder always injects its own `gradio[oauth,mcp]==<current>` into the install command, so pinning gradio==6.29.0 in requirements.txt made pip resolve two conflicting versions and the Space build failed outright with ResolutionImpossible. Use a floor version instead so the Space's pin wins. Correctness - date.today() read the machine's timezone. On Hugging Face the container runs in UTC while users are in Asia/Jakarta (UTC+7), so between 00:00 and 07:00 WIB the UTC date is still the previous day: meals logged then were filed under yesterday and /today showed nothing at all. "Today" is now derived from users.timezone via user_today(). - reminder context uses the same date, so reminder wording no longer disagrees with /today. Tests - Add a regression test that pins the clock at 00:00/03:00/06:00 WIB and asserts user_today() follows the user, not the container. - meal_type check no longer relies on server-side current_date, which s…2cdaf35 -
feat: switch to Postgres, add intent router and a warmer persona
Database - Replace SQLite (aiosqlite) with PostgreSQL via asyncpg. All state lived on the container's ephemeral filesystem, which is why every redeploy wiped it. - Add versioned migrations (database/migrations/NNN_*.sql) recorded in schema_migrations with checksums. The old CREATE-IF-NOT-EXISTS approach could not evolve the schema, and the live DB had drifted (orphaned google_calendar_tokens table). - Drop write-only daily_nutrition cache; totals recompute from food_logs so edits stay consistent. - connection.py keeps the small subset of the aiosqlite API the services use (`await db.execute`, `async with db.execute as cursor`, fetchone/fetchall) and translates ? placeholders to $n, so call sites were left untouched. - Store activity_dt as TIMESTAMPTZ and drop the string-comparison reminder query; reminders are now correct for WIB/WITA/WIT users. - Add scripts/migrate_sqlite_to_postgres.py to move the existing 4 users, 26 food logs and 160 conversations across with ids…1fcc069