The History page's "Episodes" media filter was structurally empty: both history read paths collapse episode watch events into their series display item, and the resulting series ids were then filtered against type='episode' — guaranteed zero results. The episode media scope now resolves history at episode granularity: - loadPersonalSourceIDs keeps each watched episode's own id (deduped to the most recent watch, most-recent-first) instead of collapsing to the series; ListFilters and SearchFacet share the loader, so facets on the episode-scoped history view work too. - fetchAccessibleItemsByID gains an episode-scope path through the episode catalog query executor, since episode rows never hydrate from media_items via the browse repository. Every other scope keeps the existing series-collapse behavior. Fixes #299 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
31 lines
833 B
Go
31 lines
833 B
Go
package catalog
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/Silo-Server/silo-server/internal/userstore"
|
|
)
|
|
|
|
func TestHistoryEpisodeScopeIDs(t *testing.T) {
|
|
entries := []userstore.WatchHistoryEntry{
|
|
{MediaItemID: "episode-tmdb-100-1-3"},
|
|
{MediaItemID: "movie-tmdb-555"},
|
|
{MediaItemID: "episode-tmdb-100-1-3"}, // older rewatch collapses into the first
|
|
{MediaItemID: " "},
|
|
{MediaItemID: "episode-tmdb-100-1-2"},
|
|
}
|
|
|
|
got := HistoryEpisodeScopeIDs(entries)
|
|
want := []string{"episode-tmdb-100-1-3", "movie-tmdb-555", "episode-tmdb-100-1-2"}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("HistoryEpisodeScopeIDs = %v, want %v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestHistoryEpisodeScopeIDsEmpty(t *testing.T) {
|
|
if got := HistoryEpisodeScopeIDs(nil); len(got) != 0 {
|
|
t.Fatalf("HistoryEpisodeScopeIDs(nil) = %v, want empty", got)
|
|
}
|
|
}
|