This commit is contained in:
ponzischeme89
2026-08-22 12:38:26 +12:00
parent f982d391b9
commit b3e3f62c54
26 changed files with 1279 additions and 108 deletions
+20 -4
View File
@@ -15,9 +15,18 @@ import (
)
type activeHeroResponse struct {
Placement string `json:"placement"`
Source string `json:"source"`
Rows []recommend.Row `json:"rows"`
Placement string `json:"placement"`
Source string `json:"source"`
Candidates []activeHeroCandidate `json:"candidates,omitempty"`
Rows []recommend.Row `json:"rows"`
}
type activeHeroCandidate struct {
ItemID string `json:"itemId"`
Source string `json:"source"`
Score float64 `json:"score"`
Reason string `json:"reason,omitempty"`
Pinned bool `json:"pinned"`
}
// handleActiveHero gives every section the same server-owned resolver as Home. The client
@@ -83,6 +92,9 @@ func (s *Server) resolveActiveHero(ctx context.Context, sess store.Session, plac
location := s.heroLocation()
scheduledIDs := activeHeroScheduleIDs(policy.Schedules, placement, sess.EmbyUserID, now, location)
scheduled := filterHeroPlacement(s.pinnedHeroCandidates(ctx, scheduledIDs), placement)
for index := range scheduled {
scheduled[index].Source = "time_sensitive"
}
var candidates []heroCandidate
if placement == store.HeroPlacementTVShows {
@@ -109,9 +121,13 @@ func (s *Server) resolveActiveHero(ctx context.Context, sess store.Session, plac
return response, nil
}
items := make([]json.RawMessage, 0, len(ranked))
metadata := make([]activeHeroCandidate, 0, len(ranked))
for index, candidate := range ranked {
items = append(items, injectHeroFields(candidate.Item, heroLabel(candidate, now), heroReasonForPosition(candidate, index, placementPolicy.PrimeSubtitle, now, location)))
reason := heroReasonForPosition(candidate, index, placementPolicy.PrimeSubtitle, now, location)
items = append(items, injectHeroFields(candidate.Item, heroLabel(candidate, now), reason))
metadata = append(metadata, activeHeroCandidate{ItemID: candidate.ID, Source: heroSource(candidate), Score: heroScore(candidate, now), Reason: reason, Pinned: candidate.Source == "admin_pinned"})
}
response.Candidates = metadata
response.Rows = append(response.Rows, recommend.Row{ID: "hero-" + placement, Title: "Featured", Kind: heroRowKind, Items: items})
s.loggerFor(ctx).Debug("section hero resolved", "placement", placement, "source", source, "items", len(items))
return response, nil