Remove duplicate queries #18

Open
opened 2026-06-19 02:00:49 +00:00 by maybe-yiyi · 0 comments
maybe-yiyi commented 2026-06-19 02:00:49 +00:00 (Migrated from codeberg.org)

Background

  • get_vote_instances in votes/handlers.rs looks up the event twice (once to check existence, once to use it).
  • user_name_by_id is called in a loop in list_proxy_assignments (N+1 queries), while export_event_results has its own ad-hoc name cache.

Tasks

  • Collapse the duplicate event lookup in get_vote_instances into one.
  • Extract a single cached user-name lookup helper (e.g. batch fetch by IDs, or a shared HashMap cache) and use it in both list_proxy_assignments and export_event_results.

Files: votes/handlers.rs

Commit chain should just have the two parts be in different commits, nothing complicated.

**Background** - `get_vote_instances` in `votes/handlers.rs` looks up the event twice (once to check existence, once to use it). - `user_name_by_id` is called in a loop in `list_proxy_assignments` (N+1 queries), while `export_event_results` has its own ad-hoc name cache. **Tasks** - Collapse the duplicate event lookup in `get_vote_instances` into one. - Extract a single cached user-name lookup helper (e.g. batch fetch by IDs, or a shared `HashMap` cache) and use it in both `list_proxy_assignments` and `export_event_results`. Files: `votes/handlers.rs` Commit chain should just have the two parts be in different commits, nothing complicated.
Sign in to join this conversation.
No description provided.