chore(sections): satisfy lint (wrap trakt errors, lift source/window constants)
This commit is contained in:
@@ -185,14 +185,14 @@ func (r *TrendingRefresher) refreshCombo(ctx context.Context, source, window str
|
||||
// fetchEntries pulls the raw trending list from the configured provider. A
|
||||
// nil/unconfigured provider yields an empty list (no error).
|
||||
func (r *TrendingRefresher) fetchEntries(ctx context.Context, source, window string, fetchLimit int) ([]trendingDiscoverEntry, error) {
|
||||
if source == "trakt" {
|
||||
if source == sourceTrakt {
|
||||
if r.TraktTrending == nil {
|
||||
return nil, nil
|
||||
}
|
||||
movies, movieErr := r.TraktTrending.GetCollectionPreset(ctx, "trending", "movie", fetchLimit, "")
|
||||
shows, showErr := r.TraktTrending.GetCollectionPreset(ctx, "trending", "tv", fetchLimit, "")
|
||||
if movieErr != nil && showErr != nil {
|
||||
return nil, fmt.Errorf("trakt trending: %v / %v", movieErr, showErr)
|
||||
return nil, fmt.Errorf("trakt trending: %w / %w", movieErr, showErr)
|
||||
}
|
||||
out := make([]trendingDiscoverEntry, 0, len(movies)+len(shows))
|
||||
for _, e := range movies {
|
||||
|
||||
@@ -25,22 +25,30 @@ type TrendingSnapshot struct {
|
||||
LastError string
|
||||
}
|
||||
|
||||
// Canonical trending source and window values used as snapshot keys.
|
||||
const (
|
||||
sourceTMDB = "tmdb"
|
||||
sourceTrakt = "trakt"
|
||||
windowDay = "day"
|
||||
windowWeek = "week"
|
||||
)
|
||||
|
||||
// canonicalTrendingKey normalizes a section's configured source/window into the
|
||||
// snapshot key space. Source is "trakt" only when explicitly set; everything
|
||||
// else collapses to "tmdb". Trakt ignores the time window, so it is pinned to
|
||||
// "week" to avoid duplicate identical rows. For TMDB, "day" is honored only
|
||||
// when explicitly set; anything else is "week".
|
||||
func canonicalTrendingKey(source, window string) (string, string) {
|
||||
if source != "trakt" {
|
||||
source = "tmdb"
|
||||
if source != sourceTrakt {
|
||||
source = sourceTMDB
|
||||
}
|
||||
if source == "trakt" {
|
||||
return "trakt", "week"
|
||||
if source == sourceTrakt {
|
||||
return sourceTrakt, windowWeek
|
||||
}
|
||||
if window != "day" {
|
||||
window = "week"
|
||||
if window != windowDay {
|
||||
window = windowWeek
|
||||
}
|
||||
return "tmdb", window
|
||||
return sourceTMDB, window
|
||||
}
|
||||
|
||||
// TrendingSnapshotRepository persists and reads trending_discover_snapshots.
|
||||
|
||||
Reference in New Issue
Block a user