Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

perf: resolve case users once per listing instead of once per case - #125

Merged
rnxm merged 1 commit into
devfrom
perf/case-user-resolution
Nov 12, 2026
Merged

rnxm merged 1 commit into
devfrom
perf/case-user-resolution

Conversation

@rnxm

@rnxm rnxm commented Nov 12, 2026

Copy link
Copy Markdown
Member

What

Before, CaseStore resolved users once per row. A case list of N cases whose moderators weren't cached made N sequential fetch_user API calls, and repeated ones for the same moderator.

Now _from_rows collects the distinct user IDs in a result, takes the cached users from get_user, and fetches the rest once each, concurrently, with at most 5 calls in flight. get, active, for_user and expire all use it.

Tests

  • New database test: 6 cases by one moderator who isn't cached. fetch_user is called exactly once.
  • ruff format --check, ruff check, ty check and pytest all pass (367 passed).

🤖 Generated with Claude Code

CaseStore built each case with its own get_user / fetch_user calls, so a
listing of N cases whose moderators weren't cached made N sequential API
calls. _from_rows now collects the distinct user IDs, takes cached users,
and fetches the rest concurrently (at most 5 at a time), once each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rnxm
rnxm merged commit 6a201bf into dev Nov 12, 2026
6 checks passed
@rnxm
rnxm deleted the perf/case-user-resolution branch November 12, 2026 11:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant