Jump the Review list to an artist by letter
An A–Z/# bar above the Songs and Albums lists jumps to the first artist starting with that letter. Songs come from a new /letters endpoint giving each leading character's offset; the song list now sorts case-insensitively like the album list so each letter stays together. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
095e294f4b
commit
00147aaa9e
5 files changed
+160
-16
No files matched your search
@@ -1,6 +1,11 @@
|
||||
package store
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDecodeWarnings(t *testing.T) {
|
||||
old := decodeWarnings(`["Only 3 of 9 folders match."]`)
|
||||
@@ -15,3 +20,40 @@ func TestDecodeWarnings(t *testing.T) {
|
||||
t.Fatalf("empty list should stay an empty (non-nil) list, got %#v", ws)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatchLetters(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
st, err := Open(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { st.DB.Close() })
|
||||
p := Pair{Name: "p", MasterRoot: "/m", SlaveRoot: "/s", RetentionDays: 30}
|
||||
if err := st.SavePair(ctx, &p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, rel := range []string{"beck/a.flac", "ABBA/a.flac", "Air/a.flac", "2Pac/a.flac", "Björk/a.flac", "abba/b.flac"} {
|
||||
m := Match{PairID: p.ID, RelSlave: rel, Status: StatusUnmatched, Kind: KindNone}
|
||||
if err := st.UpsertMatch(ctx, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
ls, err := st.MatchLetters(ctx, p.ID, MatchFilter{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []LetterStart{{"2", 0}, {"a", 1}, {"b", 4}}
|
||||
if !reflect.DeepEqual(ls, want) {
|
||||
t.Fatalf("letters = %+v, want %+v", ls, want)
|
||||
}
|
||||
// The offsets must agree with the listing order, whatever the case.
|
||||
ms, _, err := st.Matches(ctx, p.ID, MatchFilter{Limit: 10})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, l := range ls {
|
||||
if got := strings.ToLower(ms[l.Offset].RelSlave[:1]); got != l.Letter {
|
||||
t.Fatalf("offset %d starts with %q, want %q (listing %v)", l.Offset, got, l.Letter, ms)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user