test-web / test (push) Successful in 52s
test-go / test (push) Successful in 1m9s
test-go / integration (push) Successful in 3m31s
release / Build signed APK (releases and dev) (push) Successful in 4m32s
release / Build + push container image (push) Successful in 24s
release / Verify release artifacts (tag releases only) (push) Skipped
A new admin tab, Duplicates, beside Missing files: the proposals from the duplicate sweep, with a Sweep now trigger and a Not duplicates dismissal. Nothing on it merges or deletes; the merge is #3911. Each group shows: - whether it is identical audio or the same recording, with a match percentage from the weakest link between members - every copy's format, size, duration, path, and the likes and plays it carries (every user's; this is admin-only, and it is what decides which copy to keep) - the copy proposed to keep, and the rule that chose it The survivor rule is library.ProposeSurvivor, a pure function the merge will reuse: lossless over lossy, then the larger file, then the copy in the library longest, then lowest id. Bitrate is not in it because the scanner never fills tracks.bitrate, and for one recording at one duration a larger file is the higher bitrate. m4a is not counted as lossless: it may be AAC. The reason names the rule that separated first place from second, not every rule the winner passed. An empty report has three causes, and the page says which: still fingerprinting, the sweep has never run, or it ran and found nothing. The sweep's state and the backfill's progress come back with the groups for that reason. Groups left with fewer than two members since the sweep are not shown. GET /api/admin/library/duplicates, POST .../sweep (202, or 409 sweep_in_progress), POST .../{id}/dismiss (404 duplicate_group_not_pending when already resolved). Migration 0060 indexes play_events by track_id. Its only indexes led with user_id, so each copy's play count, and the merge's repointing of play history, would scan the whole table. Web only, like Missing files: Android has no library-health admin screens. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SQ31KQpYbStyK5y58UmPLH
174 lines
6.9 KiB
TypeScript
174 lines
6.9 KiB
TypeScript
import { createQuery, createInfiniteQuery } from '@tanstack/svelte-query';
|
|
import { api } from './client';
|
|
import { pageGetNextPageParam } from './paging';
|
|
import type {
|
|
ArtistRef,
|
|
ArtistDetail,
|
|
AlbumRef,
|
|
AlbumDetail,
|
|
Page,
|
|
SearchResponse,
|
|
TrackRef
|
|
} from './types';
|
|
|
|
export type ArtistSort = 'alpha' | 'newest';
|
|
export const ARTIST_PAGE_SIZE = 50;
|
|
export const SEARCH_SUMMARY_LIMIT = 10;
|
|
export const SEARCH_FACET_PAGE_SIZE = 50;
|
|
|
|
export const qk = {
|
|
artists: (sort: ArtistSort) => ['artists', { sort }] as const,
|
|
artist: (id: string) => ['artist', id] as const,
|
|
album: (id: string) => ['album', id] as const,
|
|
search: (q: string) => ['search', { q }] as const,
|
|
searchArtists: (q: string) => ['searchArtists', { q }] as const,
|
|
searchAlbums: (q: string) => ['searchAlbums', { q }] as const,
|
|
searchTracks: (q: string) => ['searchTracks', { q }] as const,
|
|
likedIds: () => ['likedIds'] as const,
|
|
likedTracks: () => ['likedTracks'] as const,
|
|
likedAlbums: () => ['likedAlbums'] as const,
|
|
likedArtists: () => ['likedArtists'] as const,
|
|
history: () => ['history'] as const,
|
|
// Lidarr / requests / admin.
|
|
lidarrSearch: (q: string, kind: string) =>
|
|
['lidarrSearch', { q, kind }] as const,
|
|
myRequests: () => ['myRequests'] as const,
|
|
lidarrConfig: () => ['lidarrConfig'] as const,
|
|
lidarrQualityProfiles: () => ['lidarrQualityProfiles'] as const,
|
|
lidarrMetadataProfiles: () => ['lidarrMetadataProfiles'] as const,
|
|
lidarrRootFolders: () => ['lidarrRootFolders'] as const,
|
|
adminRequests: (status?: string) =>
|
|
['adminRequests', { status: status ?? 'all' }] as const,
|
|
myQuarantine: () => ['myQuarantine'] as const,
|
|
adminQuarantine: () => ['adminQuarantine'] as const,
|
|
adminQuarantineActions: (limit?: number) =>
|
|
['adminQuarantineActions', { limit: limit ?? 50 }] as const,
|
|
adminPlaybackErrors: (resolved?: boolean) =>
|
|
['adminPlaybackErrors', { resolved: resolved ?? false }] as const,
|
|
scanStatus: () => ['scanStatus'] as const,
|
|
coverage: () => ['coverage'] as const,
|
|
fingerprintCoverage: () => ['fingerprintCoverage'] as const,
|
|
coverProviders: () => ['coverProviders'] as const,
|
|
tagProviders: () => ['tagProviders'] as const,
|
|
adminUsers: () => ['adminUsers'] as const,
|
|
adminInvites: () => ['adminInvites'] as const,
|
|
adminDiagnostics: (f: Record<string, string | number | undefined>) =>
|
|
['adminDiagnostics', f] as const,
|
|
adminMissingFiles: (offset?: number) =>
|
|
['adminMissingFiles', { offset: offset ?? 0 }] as const,
|
|
adminDuplicates: (offset?: number) =>
|
|
['adminDuplicates', { offset: offset ?? 0 }] as const,
|
|
adminDiagnosticDevices: (userId?: string) =>
|
|
['adminDiagnosticDevices', { userId: userId ?? 'all' }] as const,
|
|
smtpConfig: () => ['smtpConfig'] as const,
|
|
suggestions: (limit?: number) =>
|
|
['suggestions', { limit: limit ?? 12 }] as const,
|
|
suggestionSnoozes: () => ['suggestionSnoozes'] as const,
|
|
home: () => ['home'] as const,
|
|
albumsAlpha: () => ['albumsAlpha'] as const,
|
|
artistTracks: (artistId: string) => ['artistTracks', artistId] as const,
|
|
similarArtists: (artistId: string) => ['similarArtists', artistId] as const,
|
|
artistTopTracks: (artistId: string) => ['artistTopTracks', artistId] as const,
|
|
playlists: (kind?: 'user' | 'system' | 'all') =>
|
|
['playlists', { kind: kind ?? 'user' }] as const,
|
|
playlist: (id: string) => ['playlist', id] as const,
|
|
systemPlaylistsStatus: () => ['systemPlaylistsStatus'] as const,
|
|
// Browse indexes (#367). Keys carry no arguments — both are whole-library
|
|
// indexes, and the per-genre / per-year album lists are fetched outside
|
|
// svelte-query because their selection comes from the URL.
|
|
genres: () => ['genres'] as const,
|
|
albumYears: () => ['albumYears'] as const,
|
|
};
|
|
|
|
export function createArtistsQuery(sort: ArtistSort) {
|
|
return createInfiniteQuery({
|
|
queryKey: qk.artists(sort),
|
|
queryFn: ({ pageParam = 0 }) =>
|
|
api.get<Page<ArtistRef>>(
|
|
`/api/artists?sort=${sort}&limit=${ARTIST_PAGE_SIZE}&offset=${pageParam}`
|
|
),
|
|
initialPageParam: 0,
|
|
getNextPageParam: pageGetNextPageParam<ArtistRef>(),
|
|
});
|
|
}
|
|
|
|
export function createArtistQuery(id: string) {
|
|
return createQuery({
|
|
queryKey: qk.artist(id),
|
|
queryFn: () => api.get<ArtistDetail>(`/api/artists/${id}`),
|
|
});
|
|
}
|
|
|
|
export function createAlbumQuery(id: string) {
|
|
return createQuery({
|
|
queryKey: qk.album(id),
|
|
queryFn: () => api.get<AlbumDetail>(`/api/albums/${id}`),
|
|
});
|
|
}
|
|
|
|
export function createSimilarArtistsQuery(id: string) {
|
|
return createQuery({
|
|
queryKey: qk.similarArtists(id),
|
|
queryFn: () => api.get<ArtistRef[]>(`/api/artists/${id}/similar`),
|
|
enabled: id.length > 0,
|
|
});
|
|
}
|
|
|
|
export function createArtistTopTracksQuery(id: string) {
|
|
return createQuery({
|
|
queryKey: qk.artistTopTracks(id),
|
|
queryFn: () => api.get<TrackRef[]>(`/api/artists/${id}/top-tracks`),
|
|
enabled: id.length > 0,
|
|
});
|
|
}
|
|
|
|
export function createSearchQuery(q: string) {
|
|
return createQuery({
|
|
queryKey: qk.search(q),
|
|
queryFn: () =>
|
|
api.get<SearchResponse>(
|
|
`/api/search?q=${encodeURIComponent(q)}&limit=${SEARCH_SUMMARY_LIMIT}`
|
|
),
|
|
enabled: q.length > 0
|
|
});
|
|
}
|
|
|
|
export function createSearchArtistsInfiniteQuery(q: string) {
|
|
return createInfiniteQuery({
|
|
queryKey: qk.searchArtists(q),
|
|
queryFn: ({ pageParam = 0 }) =>
|
|
api.get<SearchResponse>(
|
|
`/api/search?q=${encodeURIComponent(q)}&limit=${SEARCH_FACET_PAGE_SIZE}&offset=${pageParam}`
|
|
).then((r) => r.artists),
|
|
initialPageParam: 0,
|
|
getNextPageParam: pageGetNextPageParam<ArtistRef>(),
|
|
enabled: q.length > 0
|
|
});
|
|
}
|
|
|
|
export function createSearchAlbumsInfiniteQuery(q: string) {
|
|
return createInfiniteQuery({
|
|
queryKey: qk.searchAlbums(q),
|
|
queryFn: ({ pageParam = 0 }) =>
|
|
api.get<SearchResponse>(
|
|
`/api/search?q=${encodeURIComponent(q)}&limit=${SEARCH_FACET_PAGE_SIZE}&offset=${pageParam}`
|
|
).then((r) => r.albums),
|
|
initialPageParam: 0,
|
|
getNextPageParam: pageGetNextPageParam<AlbumRef>(),
|
|
enabled: q.length > 0
|
|
});
|
|
}
|
|
|
|
export function createSearchTracksInfiniteQuery(q: string) {
|
|
return createInfiniteQuery({
|
|
queryKey: qk.searchTracks(q),
|
|
queryFn: ({ pageParam = 0 }) =>
|
|
api.get<SearchResponse>(
|
|
`/api/search?q=${encodeURIComponent(q)}&limit=${SEARCH_FACET_PAGE_SIZE}&offset=${pageParam}`
|
|
).then((r) => r.tracks),
|
|
initialPageParam: 0,
|
|
getNextPageParam: pageGetNextPageParam<TrackRef>(),
|
|
enabled: q.length > 0
|
|
});
|
|
}
|