1.5 KiB
1.5 KiB
id, title, status, assignee, created_date, labels, dependencies, references, priority
| id | title | status | assignee | created_date | labels | dependencies | references | priority | |
|---|---|---|---|---|---|---|---|---|---|
| ML-25 | recompact_positions issues per-row UPDATEs instead of bulk | Done | 2026-04-20 08:51 |
|
medium |
Description
GitHub: created 2026-04-05 · updated 2026-04-06 · closed 2026-04-06
Summary
RecordSets.recompact_positions/1 fetches all items into memory and issues individual UPDATE queries for each item whose position changed. The same module already demonstrates a bulk UPDATE pattern in reorder_records_in_set/2.
Why This Matters
- For a record set with N items, this can issue up to N individual UPDATE queries
- The same module's
reorder_records_in_set/2(lines 142-157) uses a single bulk UPDATE with CASE expressions — proving the better pattern is already known
Affected Files
lib/music_library/record_sets.ex(lines 239-254)
Suggested Fix
Rewrite recompact_positions/1 to use a single UPDATE ... CASE statement, consistent with reorder_records_in_set/2.
Acceptance Criteria
- Position recompaction uses a single bulk UPDATE
- Positions are correctly reassigned with no gaps
- No regression in ordering behaviour
- #1 Position recompaction uses a single bulk UPDATE
- #2 Positions are correctly reassigned with no gaps
- #3 No regression in ordering behaviour