ML-169.6: add redundant stream reload fix task
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
---
|
||||
id: ML-169.6
|
||||
title: "Fix: Redundant stream_insert + immediate full reload after CRUD"
|
||||
status: To Do
|
||||
assignee: []
|
||||
created_date: "2026-05-19 11:48"
|
||||
labels:
|
||||
- perf
|
||||
- fix
|
||||
dependencies: []
|
||||
references:
|
||||
- >-
|
||||
backlog/documents/doc-27 -
|
||||
Phase-4-Performance-Audit-Low-Hanging-Fruit-Findings.md
|
||||
modified_files:
|
||||
- lib/music_library_web/live/scrobble_rules_live/index.ex
|
||||
- lib/music_library_web/live/online_store_template_live/index.ex
|
||||
parent_task_id: ML-169
|
||||
priority: medium
|
||||
ordinal: 27000
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
<!-- SECTION:DESCRIPTION:BEGIN -->
|
||||
|
||||
Fix redundant database query pattern where `stream_insert` is immediately followed by a full `load_and_assign_*` call that negates the benefit of the incremental insert.
|
||||
|
||||
## Problem
|
||||
|
||||
After a create/save operation, the code performs a correct `stream_insert` (incremental insert) but then immediately calls `load_and_assign_*/2` which does a full `stream(..., reset: true)` — completely negating the benefit of `stream_insert`. Same pattern exists for delete operations.
|
||||
|
||||
## Files
|
||||
|
||||
- `lib/music_library_web/live/scrobble_rules_live/index.ex:247-253` — `handle_info({Form, {:created, ...})` does `stream_insert` then `load_and_assign_rules`
|
||||
- `lib/music_library_web/live/online_store_template_live/index.ex:195-201` — `handle_info({Form, {:saved, ...})` does `stream_insert` then `load_and_assign_templates`
|
||||
|
||||
## Impact
|
||||
|
||||
Wastes a database query after every create/save/delete operation. Medium severity because these are infrequent user actions (not per-keystroke or per-tick).
|
||||
|
||||
## Fix
|
||||
|
||||
Remove the `load_and_assign_*` call after `stream_insert`. The stream already has the correct data. For delete, `stream_delete` already removes the item from the stream — no full reload needed.
|
||||
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
<!-- AC:BEGIN -->
|
||||
|
||||
- [ ] #1 Creating a scrobble rule inserts it into the stream without a full reload
|
||||
- [ ] #2 Saving an online store template inserts it into the stream without a full reload
|
||||
- [ ] #3 Deleting an item removes it from the stream without a full reload
|
||||
- [ ] #4 Stream order remains correct after insert/delete operations
|
||||
- [ ] #5 No duplicate items appear after create/save
|
||||
<!-- AC:END -->
|
||||
Reference in New Issue
Block a user