From 04a9b0b0bd581e66832cb95ae42cfd30fa81dd56 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sun, 5 Jul 2026 22:06:00 +0200 Subject: [PATCH] feat: share cache between top pick and top picks endpoints --- internal/anime/recommendations.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/anime/recommendations.go b/internal/anime/recommendations.go index 9d1ce1fd..09be6fc3 100644 --- a/internal/anime/recommendations.go +++ b/internal/anime/recommendations.go @@ -32,7 +32,11 @@ type topPicksCache struct { const topPicksRefreshTimeout = 30 * time.Second func (s *animeService) GetTopPickForYou(_ context.Context, userID string) (domain.CatalogSectionData, error) { - return s.getCachedTopPicksForYou(userID, recommendations.TopPickLimit), nil + data := s.getCachedTopPicksForYou(userID, recommendations.TopPicksLimit) + if len(data.Animes) > recommendations.TopPickLimit { + data.Animes = data.Animes[:recommendations.TopPickLimit] + } + return data, nil } func (s *animeService) GetTopPicksForYou(_ context.Context, userID string) (domain.CatalogSectionData, error) {