isRamseyMode() called twice per snowball projection request #58

Closed
opened 2026-05-16 21:43:25 -05:00 by null · 1 comment
Owner

Severity: MEH

Affected Files

  • routes/snowball.jsgetDebtBills() and projection handler

Problem

isRamseyMode() hits SQLite on every call with no caching:

// Called in getDebtBills()
const ramseyMode = isRamseyMode(db, userId);
// ... then projection logic also calls it or the value is re-fetched

Two reads per request for the same setting value that doesn't change within a single request.

Impact

  • Minor performance waste — two SQLite reads for one boolean value
  • No user-visible impact
  • Could matter under high request volume

Fix

Call isRamseyMode() once at the top of the request handler and pass the result through:

const ramseyMode = isRamseyMode(db, userId);
const debtBills = getDebtBills(db, userId, ramseyMode);
// ... use ramseyMode in projection logic

Or add a simple request-scoped cache.

Acceptance Criteria

  • isRamseyMode() is called at most once per request
  • Snowball projection results unchanged
## Severity: MEH ⚪ ## Affected Files - `routes/snowball.js` — `getDebtBills()` and projection handler ## Problem `isRamseyMode()` hits SQLite on every call with no caching: ```javascript // Called in getDebtBills() const ramseyMode = isRamseyMode(db, userId); // ... then projection logic also calls it or the value is re-fetched ``` Two reads per request for the same setting value that doesn't change within a single request. ## Impact - Minor performance waste — two SQLite reads for one boolean value - No user-visible impact - Could matter under high request volume ## Fix Call `isRamseyMode()` once at the top of the request handler and pass the result through: ```javascript const ramseyMode = isRamseyMode(db, userId); const debtBills = getDebtBills(db, userId, ramseyMode); // ... use ramseyMode in projection logic ``` Or add a simple request-scoped cache. ## Acceptance Criteria - [ ] `isRamseyMode()` is called at most once per request - [ ] Snowball projection results unchanged
null added the
priority:medium
backend
labels 2026-05-16 21:43:25 -05:00
Author
Owner

Fixed in e41f413. getDebtBills now accepts an explicit ramseyMode param, eliminating the redundant DB call.

Fixed in `e41f413`. `getDebtBills` now accepts an explicit `ramseyMode` param, eliminating the redundant DB call.
null closed this issue 2026-06-03 20:46:49 -05:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
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: null/BillTracker#58
No description provided.