sync: Backfill history entries for merged PRs #29

Merged
arne merged 7 commits from idea-3-history-backfill into main 2026-04-06 20:04:17 +02:00
Owner

Summary

  • Make the periodic sync resilient by backfilling history entries for merged PRs missed by webhooks (late webhook setup, downtime, network issues)
  • Add UNIQUE(project_id, pr_number) constraint to history_entries so both webhooks and sync are idempotent
  • New ListMergedPRsWithoutHistory query finds gaps; BackfillHistory syncer method fills them at startup and every 15 minutes

Closes idea #3

Test plan

  • TestCreateHistoryEntryIdempotent — duplicate insert returns (nil, nil), no error, one row
  • TestListMergedPRsWithoutHistory — merged without history returned, merged with history excluded, open excluded
  • TestBackfillHistory — end-to-end: sync merged PR, backfill creates entry, second run is idempotent
  • All existing tests pass (go test ./...)

🤖 Generated with Claude Code

## Summary - Make the periodic sync resilient by backfilling history entries for merged PRs missed by webhooks (late webhook setup, downtime, network issues) - Add `UNIQUE(project_id, pr_number)` constraint to `history_entries` so both webhooks and sync are idempotent - New `ListMergedPRsWithoutHistory` query finds gaps; `BackfillHistory` syncer method fills them at startup and every 15 minutes Closes idea #3 ## Test plan - [x] `TestCreateHistoryEntryIdempotent` — duplicate insert returns (nil, nil), no error, one row - [x] `TestListMergedPRsWithoutHistory` — merged without history returned, merged with history excluded, open excluded - [x] `TestBackfillHistory` — end-to-end: sync merged PR, backfill creates entry, second run is idempotent - [x] All existing tests pass (`go test ./...`) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a query that returns merged pull requests missing history entries,
needed for the sync backfill mechanism.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Calls BackfillHistory at server startup (after SyncAllPullRequests)
and periodically during the sync ticker (every 15 minutes).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
arne merged commit 0f4d70daaa into main 2026-04-06 20:04:17 +02:00
arne deleted branch idea-3-history-backfill 2026-04-06 20:04:17 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
arne/orbit!29
No description provided.