feat(server): improve calendar sync queue (#14783)

#### PR Dependency Tree


* **PR #14783** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
  * Configurable request timeout for calendar integrations.
* Calendar polling now enqueues per-subscription sync jobs (larger
batch) for improved throughput.

* **Bug Fixes / Improvements**
* Persisted next-sync timestamps and retry counts for more reliable
scheduling and retry behavior.
* Exponential backoff and webhook renewal now update scheduling
consistently.

* **Refactor**
* Calendar sync flow moved to a job-queue-driven design for better
concurrency and observability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-04-05 10:52:18 +08:00
committed by GitHub
parent bfcf7fc2ba
commit d975bf46fb
17 changed files with 352 additions and 307 deletions
@@ -0,0 +1,27 @@
-- AlterTable
ALTER TABLE
"calendar_subscriptions"
ADD
COLUMN "next_sync_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD
COLUMN "sync_retry_count" INTEGER NOT NULL DEFAULT 0;
UPDATE
"calendar_subscriptions" AS s
SET
"next_sync_at" = CASE
WHEN s."last_sync_at" IS NULL THEN CURRENT_TIMESTAMP
ELSE s."last_sync_at" + make_interval(
mins => COALESCE(a."refresh_interval_minutes", 30)
)
END
FROM
"calendar_accounts" AS a
WHERE
a."id" = s."account_id";
-- CreateIndex
CREATE INDEX "calendar_subscriptions_custom_channel_id_idx" ON "calendar_subscriptions"("custom_channel_id");
-- CreateIndex
CREATE INDEX "calendar_subscriptions_enabled_next_sync_at_idx" ON "calendar_subscriptions"("enabled", "next_sync_at");