Skip to content

Daily audio lesson: per-user preference + nightly pre-generation#641

Merged
mircealungu merged 1 commit into
masterfrom
daily-audio-lesson-backend
May 27, 2026
Merged

Daily audio lesson: per-user preference + nightly pre-generation#641
mircealungu merged 1 commit into
masterfrom
daily-audio-lesson-backend

Conversation

@mircealungu
Copy link
Copy Markdown
Member

Backend half of the daily-delivery Listen redesign (frontend is a separate PR in zeeguu/web). The model shifts from "tap Generate every day" to "configure once, a fresh lesson is waiting each morning."

What's here

  • UserPreference — per-language keys daily_audio_lesson_type_<lang> and daily_audio_lesson_suggestion_<lang>, plus a get_daily_audio_lesson_config(user, lang) helper. "Enabled" == a type is set. The subject is stored verbatim (exactly what the user typed); canonicalization still happens at generation time.
  • save_user_preferences — persists the new keys (prefix-matched), so GET /user_preferences already returns them.
  • tools/generate_daily_audio_lessons.py — nightly job modeled on precompute_upcoming_meaning_lessons.py. For each recently-active user who has a daily lesson configured for their learned language and no lesson yet for their local "today", it runs the existing prepare_lesson_generation + generate_daily_lesson pipeline synchronously. Idempotent (skips users who already have today's lesson); --dry-run and --user-id for testing; per-user timeout; optional --send-email summary.

Notes

  • Pure backend; no behavior change until the web PR ships. The web flow also generates on demand (first day / cron miss / timezone), so the cron is a latency optimization, not a correctness requirement.
  • The crontab entry is in the ops repo (separate PR). Merge/deploy this one first so the tool exists before the schedule references it.

Test

source ~/code/zeeguu/api/.venv/bin/activate && python tools/generate_daily_audio_lessons.py --dry-run --user-id <id>

🤖 Generated with Claude Code

Backend for the daily-delivery Listen redesign. Instead of generating a
lesson on demand each day, the user configures a daily lesson once and a
fresh one is pre-generated so it's waiting when they open the app.

- UserPreference: per-language keys daily_audio_lesson_type_<lang> /
  daily_audio_lesson_suggestion_<lang> (+ get_daily_audio_lesson_config
  helper). The subject is stored verbatim — canonicalization stays at
  generation time.
- save_user_preferences persists those keys (prefix-matched).
- tools/generate_daily_audio_lessons.py: nightly job that, for each
  recently-active opted-in user with no lesson yet for their local today,
  runs the existing prepare+generate pipeline synchronously. Idempotent;
  --dry-run / --user-id for testing.

The crontab entry lives in the ops repo (separate PR); merge/deploy this
first so the tool exists before the schedule references it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

ArchLens - No architecturally relevant changes to the existing views

@mircealungu mircealungu merged commit d3a47f6 into master May 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant