feat(requests): show ingest progress while requests are in flight
After Lidarr accepts a request the local reconciler imports albums and
tracks as they arrive — but until the request hit 'completed' the
operator had no way to see "is anything happening?" The /requests and
/admin/requests rows now surface a live progress line whenever the
request's matched entity has children in our library.
Backend:
- New CountAlbumsByArtist + CountTracksByArtist sqlc queries.
- requestView gains imported_album_count and imported_track_count.
- New fillProgress helper computes them from the matched entity:
- kind=artist → counts albums + tracks under matched_artist_id
- kind=album → counts tracks under matched_album_id
- kind=track → 1 once matched_track_id is set
N+1 in the list endpoints; acceptable at admin scale.
- handleListRequests, handleGetRequest, and handleListAdminRequests
populate the new fields on every response.
Frontend:
- LidarrRequest TS type extended with the two counters.
- Both the operator's /requests page and the admin /admin/requests
page render an accent-colored line under the row meta when at
least one counter is non-zero, e.g.:
Artist: "5 albums · 47 tracks ingested"
Album: "12 tracks ingested"
Track: "Track ingested"
- Updated test fixtures to include the new required fields.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -66,7 +66,9 @@ const baseRow: LidarrRequest = {
|
||||
matched_album_id: null,
|
||||
matched_artist_id: null,
|
||||
requested_at: '2026-01-01T00:00:00Z',
|
||||
updated_at: '2026-01-01T00:00:00Z'
|
||||
updated_at: '2026-01-01T00:00:00Z',
|
||||
imported_album_count: 0,
|
||||
imported_track_count: 0
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -41,7 +41,9 @@ const mockRow: LidarrRequest = {
|
||||
matched_album_id: null,
|
||||
matched_artist_id: null,
|
||||
requested_at: '2026-01-01T00:00:00Z',
|
||||
updated_at: '2026-01-01T00:00:00Z'
|
||||
updated_at: '2026-01-01T00:00:00Z',
|
||||
imported_album_count: 0,
|
||||
imported_track_count: 0
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -123,6 +123,11 @@ export type LidarrRequest = {
|
||||
matched_artist_id?: string | null;
|
||||
requested_at: string;
|
||||
updated_at: string;
|
||||
// Live ingest counters. Server fills these from the matched entity's
|
||||
// children. Useful for in-flight requests so the operator can see
|
||||
// "5 albums · 47 tracks" while Lidarr is still working on the rest.
|
||||
imported_album_count: number;
|
||||
imported_track_count: number;
|
||||
};
|
||||
|
||||
export type LidarrConfig = {
|
||||
|
||||
@@ -256,6 +256,18 @@
|
||||
<div class="truncate text-sm text-text-secondary">
|
||||
{rowMeta(r)}
|
||||
</div>
|
||||
{#if r.imported_album_count > 0 || r.imported_track_count > 0}
|
||||
<div class="text-sm text-accent" data-testid="ingest-progress">
|
||||
{#if r.kind === 'artist'}
|
||||
{r.imported_album_count} {r.imported_album_count === 1 ? 'album' : 'albums'}
|
||||
· {r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{:else if r.kind === 'album'}
|
||||
{r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{:else}
|
||||
Track ingested
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if r.kind === 'track' && r.album_title}
|
||||
<div class="text-sm text-text-secondary" data-testid="track-disclosure">
|
||||
Approving will add the album <em class="font-medium text-text-primary">{r.album_title}</em>.
|
||||
|
||||
@@ -37,7 +37,9 @@ const baseRow: LidarrRequest = {
|
||||
artist_name: 'Boards of Canada',
|
||||
album_title: 'Geogaddi',
|
||||
requested_at: '2026-04-29T10:00:00Z',
|
||||
updated_at: '2026-04-29T10:00:00Z'
|
||||
updated_at: '2026-04-29T10:00:00Z',
|
||||
imported_album_count: 0,
|
||||
imported_track_count: 0
|
||||
};
|
||||
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
@@ -103,6 +103,18 @@
|
||||
<div class="truncate text-sm text-text-secondary">
|
||||
{rowMeta(r)}
|
||||
</div>
|
||||
{#if r.imported_album_count > 0 || r.imported_track_count > 0}
|
||||
<div class="text-sm text-accent" data-testid="ingest-progress">
|
||||
{#if r.kind === 'artist'}
|
||||
{r.imported_album_count} {r.imported_album_count === 1 ? 'album' : 'albums'}
|
||||
· {r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{:else if r.kind === 'album'}
|
||||
{r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{:else}
|
||||
Track ingested
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if r.status === 'rejected' && r.notes}
|
||||
<div class="text-sm text-text-secondary" data-testid="rejection-notes">
|
||||
{r.notes}
|
||||
|
||||
@@ -60,6 +60,8 @@ function req(over: Partial<LidarrRequest> = {}): LidarrRequest {
|
||||
matched_artist_id: null,
|
||||
requested_at: '2026-04-28T12:00:00Z',
|
||||
updated_at: '2026-04-28T12:00:00Z',
|
||||
imported_album_count: 0,
|
||||
imported_track_count: 0,
|
||||
...over
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user