feat: multi-step cron — check-research + ingest refactor + pg_cron#604
Merged
codercatdev merged 2 commits intodevfrom Mar 5, 2026
Merged
feat: multi-step cron — check-research + ingest refactor + pg_cron#604codercatdev merged 2 commits intodevfrom
codercatdev merged 2 commits intodevfrom
Conversation
…ron SQL - NEW: app/api/cron/check-research/route.ts (690 lines) Polls NotebookLM research status every 5min. When complete: imports sources, generates 5 infographics, enriches script, transitions to script_ready. Includes stuck detection (>30min → flagged). - MODIFIED: app/api/cron/ingest/route.ts Fire-and-forget research: creates notebook + starts research in ~15s, creates doc as "researching". Returns immediately. Non-research path unchanged (straight to script_ready). - MODIFIED: sanity/schemas/documents/automatedVideo.ts Added "researching" status, researchNotebookId, researchTaskId, trendScore, trendSources fields. - NEW: supabase/migrations/002_cron_schedules.sql pg_cron schedules for all 4 pipeline crons.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…on, researchData field Co-authored-by: research <research@miriad.systems>
codercatdev
commented
Mar 5, 2026
Contributor
Author
codercatdev
left a comment
There was a problem hiding this comment.
✅ Re-review: All 4 blockers fixed
Verified commit ebef51c:
researchDatafield — added to schema astype: 'text', hidden: true✅after()pattern — Phase 3 usesafter(async () => processResearchingDoc(...))with error handling that flags failed docs.maxDuration = 300. Returns 200 before processing. ✅- CRON_SECRET fail-closed — Both
check-researchANDingestnow check!cronSecret→ 503 before comparison. ✅ - Stuck detection independent — Phase 1 queries, Phase 2 flags stuck docs (no NotebookLM needed), Phase 3 only calls
initAuth()if active docs exist. ✅
Minor fixes also confirmed: _updatedAt for stuck detection, schema description cleaned.
Architecture is solid. Merging to dev.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits the blocking 10+ minute NotebookLM research step into a fire-and-forget + polling architecture, matching the existing
check-renderspattern. All cron schedules defined in Supabase pg_cron migration.Replaces #603 (which had stale files from other branches in the diff).
New Status Flow
When
ENABLE_NOTEBOOKLM_RESEARCHis NOT set, ingest goes straight to"script_ready"— no change to existing behavior.Files Changed (4 files only — clean diff)
NEW:
app/api/cron/check-research/route.ts(690 lines)Polls NotebookLM research status for docs in
"researching"state:"script_ready"Patterns from
check-renders:CRON_SECRETbearer authfetchCache = 'force-no-store'+maxDuration = 60"researching"→ flagged)MODIFIED:
app/api/cron/ingest/route.tsconductResearch()call (was 10+ minutes)researchNotebookIdandresearchTaskIdon Sanity doc"researching"when NotebookLM enabled,"script_ready"when notMODIFIED:
sanity/schemas/documents/automatedVideo.ts"researching"to pipeline status optionsresearchNotebookId,researchTaskIdfields (hidden)trendScore,trendSourcesfieldsNEW:
supabase/migrations/002_cron_schedules.sqlingest-daily0 10 * * */api/cron/ingestcheck-research*/5 * * * */api/cron/check-researchcheck-renders*/5 * * * */api/cron/check-renderssponsor-outreach0 9 * * 1,4/api/cron/sponsor-outreachPrerequisites: Set
app.site_urlandapp.cron_secretas Supabase config vars.