Skip to main content
← Back to list
01Issue
FeatureOpenSwamp Club
AssigneesNone

Relationships

#804 Batch step 2 of enrichAuthorPlans (per-collective subscription reads)

Opened by keeb · 6/24/2026

In lib/app/lab/enrich-author-plans.ts, step 1 (author → collectives) was batched into a single bulk read via CollectiveQueryService.listCollectivesForUsers. Step 2 was left as a fan-out:

await Promise.all(allCollectiveIds.map(async (id) => {
  const sub = await deps.subscriptionRepo.findByCollectiveId(id);
  ...
}));

This issues one billing_subscription read per distinct collective (parallel, but N queries). On a cold cache miss with ~22 issue authors that is ~22-30 reads, to discover that only 2 subscriptions exist in the entire system.

Proposal: add SubscriptionRepository.findByCollectiveIds(ids: string[]) backed by a single { collectiveId: { $in: ids } } query, and replace the map/Promise.all in step 2 with one call — matching how step 1 was already batched. This makes the cold path O(1) in queries regardless of author/collective count and removes the half-batched asymmetry.

Impact is bounded today (step 2 only runs on cache miss, ~once per 60s TTL per replica), so this is cleanup/consistency, not an outage fix. Context: follow-up to the lab perf work in #725/#729.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

6/24/2026, 7:30:35 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.