mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-18 08:08:45 +01:00
fix(artwork): surface priority names in the explain UI and tidy up loose ends
Moves the CLI's priority-name lookup into core/artwork so the native API and UI can render "scan" instead of a bare priority number, replaces a brittle string comparison with a presence check on the stored artwork, renders the source path in the details section, drops the unused hash field, and aligns date rendering with the rest of the dialog.
This commit is contained in:
parent
fd46e594e1
commit
f283da0630
9 changed files with 73 additions and 49 deletions
|
|
@ -28,15 +28,15 @@ type traceStepDTO struct {
|
|||
|
||||
type storedDTO struct {
|
||||
Source string `json:"source"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
SourcePath string `json:"sourcePath,omitempty"`
|
||||
AttemptedAt string `json:"attemptedAt,omitempty"`
|
||||
}
|
||||
|
||||
type queuedDTO struct {
|
||||
Priority int `json:"priority"`
|
||||
Attempts int `json:"attempts"`
|
||||
RetryAt string `json:"retryAt,omitempty"`
|
||||
Priority int `json:"priority"`
|
||||
PriorityName string `json:"priorityName"`
|
||||
Attempts int `json:"attempts"`
|
||||
RetryAt string `json:"retryAt,omitempty"`
|
||||
}
|
||||
|
||||
type configDTO struct {
|
||||
|
|
@ -121,16 +121,16 @@ func toExplainDTO(rep artwork.ExplainReport) explainDTO {
|
|||
if rep.Stored != nil {
|
||||
dto.Stored = &storedDTO{
|
||||
Source: rep.Stored.Source,
|
||||
Hash: rep.Stored.Hash,
|
||||
SourcePath: rep.Stored.SourcePath,
|
||||
AttemptedAt: rfc3339(rep.Stored.AttemptedAt),
|
||||
}
|
||||
}
|
||||
if rep.Queued != nil {
|
||||
dto.Queued = &queuedDTO{
|
||||
Priority: rep.Queued.Priority,
|
||||
Attempts: rep.Queued.Attempts,
|
||||
RetryAt: rfc3339(rep.Queued.RetryAt),
|
||||
Priority: rep.Queued.Priority,
|
||||
PriorityName: artwork.PriorityName(rep.Queued.Priority),
|
||||
Attempts: rep.Queued.Attempts,
|
||||
RetryAt: rfc3339(rep.Queued.RetryAt),
|
||||
}
|
||||
}
|
||||
if steps := rep.LastAttemptFailed(); len(steps) > 0 {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ var _ = Describe("GET /artwork/explain", func() {
|
|||
|
||||
Expect(got["stored"]).To(Equal(map[string]any{
|
||||
"source": "external:deezer",
|
||||
"hash": "abc",
|
||||
"sourcePath": "/music/Radiohead/folder.jpg",
|
||||
"attemptedAt": attemptedAt.Format(time.RFC3339),
|
||||
}))
|
||||
|
|
@ -128,9 +127,10 @@ var _ = Describe("GET /artwork/explain", func() {
|
|||
var got map[string]any
|
||||
Expect(json.Unmarshal(w.Body.Bytes(), &got)).To(Succeed())
|
||||
Expect(got["queued"]).To(Equal(map[string]any{
|
||||
"priority": float64(model.ArtworkPriorityScan),
|
||||
"attempts": float64(1),
|
||||
"retryAt": retryAt.Format(time.RFC3339),
|
||||
"priority": float64(model.ArtworkPriorityScan),
|
||||
"priorityName": "scan",
|
||||
"attempts": float64(1),
|
||||
"retryAt": retryAt.Format(time.RFC3339),
|
||||
}))
|
||||
Expect(got["lastAttemptFailed"]).To(Equal([]any{
|
||||
map[string]any{"candidate": "external:deezer", "outcome": "error", "detail": "timeout"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue