Files
music_library/backlog/archive/tasks/ml-23 - StatsLive.Index-runs-4-sequential-queries-in-mount.md
2026-05-04 21:22:27 +01:00

1.4 KiB

id, title, status, assignee, created_date, labels, dependencies, references, priority
id title status assignee created_date labels dependencies references priority
ML-23 StatsLive.Index runs 4+ sequential queries in mount To Do
2026-04-20 08:51
https://github.com/cloud8421/music_library/issues/156
medium

Description

GitHub: created 2026-04-05 · updated 2026-04-09 · closed 2026-04-09 · not planned

Summary

StatsLive.Index mount calls get_latest_record(), count_records_by_artist(), count_records_by_genre(), count_records_by_release_year(), and more as separate sequential queries with no batching or async loading.

Why This Matters

  • Each query is a separate database round-trip
  • Mount blocks until all queries complete, delaying initial page render
  • Lines 54-91 assign 9+ data structures simultaneously

Affected Files

  • lib/music_library_web/live/stats_live/index.ex (lines 54-91)

Suggested Fix

Use start_async or assign_async to load stats data concurrently after mount, showing placeholder/loading states for each section.

Acceptance Criteria

  • Stats page initial render is faster
  • Data loads concurrently where possible
  • Loading states are shown while data is fetched
  • #1 Stats page initial render is faster
  • #2 Data loads concurrently where possible
  • #3 Loading states are shown while data is fetched