1.3 KiB
1.3 KiB
id, title, status, assignee, created_date, labels, dependencies, references, priority
| id | title | status | assignee | created_date | labels | dependencies | references | priority | |
|---|---|---|---|---|---|---|---|---|---|
| ML-22 | Search + count function pairs duplicate query logic | Done | 2026-04-20 08:50 |
|
medium |
Description
GitHub: created 2026-04-05 · updated 2026-04-09 · closed 2026-04-09
Summary
Multiple contexts have paired search/count functions that duplicate the same query construction logic — building the query once for results, then rebuilding it identically for the count.
Evidence
ListeningStats.list_tracks(lines 173-186) andsearch_tracks_count(lines 237-250) repeat LIKE/JSON extraction logicArtists.search_by_name/2(lines 83-104) andsearch_by_name_count/1(lines 106-122) repeat LIKE pattern and fragment logic
Affected Files
lib/music_library/listening_stats.exlib/music_library/artists.ex
Suggested Fix
Extract the shared query builder into a private function that both the search and count functions use.
Acceptance Criteria
- Query logic is defined once per search domain
- No regression in search results or counts
- #1 Query logic is defined once per search domain
- #2 No regression in search results or counts