Skip to content

Commit 6e79931

Browse files
refactor: update cache_profile_and_watched_sets to return profile and watched sets, simplifying retrieval in ManifestService and CatalogService
1 parent 60fbd0c commit 6e79931

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

app/services/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async def cache_library_and_profiles(
103103
for content_type in ["movie", "series"]:
104104
try:
105105
logger.info(f"[{redact_token(token)}] Building and caching profile for {content_type}")
106-
await cache_profile_and_watched_sets(
106+
_, _, _ = await cache_profile_and_watched_sets(
107107
token, content_type, integration_service, library_items, bundle, auth_key
108108
)
109109
logger.debug(f"[{redact_token(token)}] Cached profile and watched sets for {content_type}")

app/services/recommendation/catalog_service.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,9 @@ async def get_catalog(
135135
else:
136136
# Build profile if not cached
137137
logger.info(f"[{redact_token(token)}...] Profile not cached for {content_type}, building from library")
138-
await cache_profile_and_watched_sets(
138+
profile, watched_tmdb, watched_imdb = await cache_profile_and_watched_sets(
139139
token, content_type, integration_service, library_items, bundle, auth_key
140140
)
141-
# Fetch the newly cached data
142-
cached_data = await user_cache.get_profile_and_watched_sets(token, content_type)
143-
if cached_data:
144-
profile, watched_tmdb, watched_imdb = cached_data
145-
else:
146-
# Fallback: profile build may have failed
147-
profile = None
148-
watched_tmdb = set()
149-
watched_imdb = set()
150141

151142
whitelist = await integration_service.get_genre_whitelist(profile, content_type) if profile else set()
152143

app/utils/catalog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async def cache_profile_and_watched_sets(
3838
)
3939

4040
await user_cache.set_profile_and_watched_sets(token, content_type, profile, watched_tmdb, watched_imdb)
41+
return profile, watched_tmdb, watched_imdb
4142

4243

4344
def get_config_id(catalog) -> str | None:

0 commit comments

Comments
 (0)