[HIGH] Refactor getNextPaydays to mathematical computation - eliminate day-by-day loop #37
Labels
No labels
blocked:needs-human
blocked:verify-failed
bug
feature-request
quickfix
security/high
security/medium
test-coverage
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/subvault#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Location:
backend/src/services/PaydayService.ts:24-42Problem:
getNextPaydaysuses a brute-forcewhileloop iterating every calendar day untilcountpaydays are found. For biweekly/monthly schedules, this iterates 30–350+ days per call.Impact: O(days) per lookup. For monthly schedules near month boundaries, this is 10–1,000x slower than necessary.
Fix: Replace with arithmetic:
start + ceil((today - start) / 7) * 7start + ceil((today - start) / 14) * 14new Date(today.getFullYear(), today.getMonth(), dayOfMonth)[d1, d2] >= todayEffort: ~2 hours