Big changes

This commit is contained in:
ponzischeme89
2026-07-29 15:26:27 +12:00
parent 8d6cf2f5a1
commit 70914400b4
62 changed files with 7501 additions and 744 deletions
+23 -2
View File
@@ -56,14 +56,22 @@ type Syncer struct {
// is borrowed instead.
serviceCred emby.Credentials
mu sync.Mutex
running bool
mu sync.Mutex
running bool
afterSync func()
}
func NewSyncer(embyClient *emby.Client, st *store.Store, serviceCred emby.Credentials, log *slog.Logger) *Syncer {
return &Syncer{emby: embyClient, store: st, serviceCred: serviceCred, log: log}
}
// SetAfterSync installs the inexpensive invalidation callback used by derived data.
func (s *Syncer) SetAfterSync(callback func()) {
s.mu.Lock()
defer s.mu.Unlock()
s.afterSync = callback
}
// Result summarises one import.
type Result struct {
Kind string `json:"kind"`
@@ -150,6 +158,12 @@ func (s *Syncer) Sync(ctx context.Context, kind, trigger string) (Result, error)
"kind", kind, "trigger", trigger, "seen", result.Seen,
"upserted", result.Upserted, "removed", result.Removed,
"duration", result.Duration.Round(time.Millisecond))
s.mu.Lock()
afterSync := s.afterSync
s.mu.Unlock()
if afterSync != nil {
afterSync()
}
return result, nil
}
@@ -345,5 +359,12 @@ func searchText(parsed syncItem) string {
parts = append(parts, strconv.Itoa(*parsed.ProductionYear))
}
parts = append(parts, parsed.Genres...)
// Studios too, so "A24" or "Pixar" finds a shelf's worth of titles. Existing rows
// keep their old text until the next full import rewrites them.
for _, studio := range parsed.Studios {
if studio.Name != "" {
parts = append(parts, studio.Name)
}
}
return strings.Join(parts, " ")
}
+17
View File
@@ -70,6 +70,23 @@ func TestSearchTextIncludesSeriesNameSoEpisodesAreFindable(t *testing.T) {
}
}
func TestSearchTextIncludesStudiosSoAStudioNameFindsItsTitles(t *testing.T) {
text := searchText(syncItem{
Name: "Everything Everywhere All at Once",
Type: "Movie",
Studios: []struct {
Name string `json:"Name"`
}{{Name: "A24"}, {Name: ""}},
})
if !strings.Contains(text, "A24") {
t.Fatalf("search text %q is missing the studio", text)
}
if strings.Contains(text, " ") {
t.Fatalf("an unnamed studio should be skipped, not joined as a gap: %q", text)
}
}
func TestSearchTextDoesNotRepeatTheTitleForAMovie(t *testing.T) {
text := searchText(syncItem{Name: "Dune", Type: "Movie", SeriesName: "Dune"})