Skip to content

perf(citations): rebuild citation rollups shortly after a topic move - #1006

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
Apu-Emdad:fix/citation-rollup-rebuild-schedule
Oct 13, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
Apu-Emdad:fix/citation-rollup-rebuild-schedule

Conversation

@Apu-Emdad

Copy link
Copy Markdown

Summary

The topic-move rebuild queue (citation_rollup_rebuilds) was only drained at the end of the nightly sweep, so the Citations topic filter kept showing a moved prompt under its old topic for up to a day.

  • rebuildQueuedCitationRollups() now runs every 5 minutes via node-cron, next to the existing schedules in server.js (cloud and self-hosted; skipped in development like the other startup jobs). The nightly call stays as the fallback.
  • Runs never overlap: an in-flight guard makes a call made during a run return at once with skipped: true. It covers both callers (the schedule and the nightly sweep) and is released in finally, so a failed run doesn't block later ones.
  • An empty queue is still a single select. No SQL or migration changes.

How to test: cd server && npx vitest run. New tests cover the overlap guard (skip during a run, run again after it ends), a rerun after a thrown run, and the one-query empty queue. 1034/1034 pass; eslint and prettier --check are clean on the changed files.

Related issue

Closes #1001

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/) — N/A, server-only change (server eslint passes)
  • yarn typecheck passes (run from web/) — N/A, server-only change
  • yarn format:check passes (run from web/) — N/A, server-only change (server prettier --check passes)
  • Changes are focused — one concern per PR

@gkhngyk
gkhngyk merged commit 7c369f1 into ansvisor:main Oct 13, 2026
6 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.

perf(citations): rebuild citation rollups shortly after a topic move, not at the nightly sweep

3 participants