fix(api): repair list ORDER BY misuse + time-entries count placeholders (PMS-145) #116
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pms-145-time-entries-count-placeholders"
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?
What
Closes PMS-145.
GET /api/v1/time-entriesreturned 500 (found via the ticket detail page's Time Logged section, which filters byticket_id). Two independent bugs, both fixed here.1. ORDER BY misuse (the actual 500, and broader)
PaginationParams::order_byappends a direction to a single column name, but four callers passed adefault_fieldthat already embedded a direction:time_tracking::list_time_entries"date DESC, start_time DESC"ORDER BY date DESC, start_time DESC DESC-> 500billing::list_invoices"invoice_date DESC"... DESC DESC-> 500billing::list_payments"payment_date DESC"... DESC DESC-> 500projects::list_projects"created_at DESC"... DESC DESC-> 500So those list endpoints 500'd on every call (filtered or not). Bare-column callers (tickets, contacts) were unaffected. Fixed each to pass a bare column (default direction is already DESC), and hardened
order_byto keep only the first whitespace token so this can't recur.2. Count-query placeholder bug (latent behind #1)
list_time_entriesreused onewhere_clausefor both queries, but the data query numbers filters from$4while the count query binds only$1then filters from$2- so with any filter the count referenced an unbound$4. Fixed with independent numbering (mirrorsbilling::list_invoices).Tests
Extends the time-tracking integration test to list the logged entry filtered by
ticket_idand assert 200 + entry present + total.cargo fmt --checkclean;cargo clippy --lib --testsclean.Unblocks
mokosh-apps PR #68 (MAPPS-123) Time Logged section, which degrades gracefully until this lands.
🤖 Generated with Claude Code