Added .cache_ready() to GuidGuidRecommender

Also force empty lists to return if the cache is cold
the cache is cold
This commit is contained in:
Victor Ng 2020-08-27 16:15:25 -04:00
Родитель cd0bb8a2ee
Коммит d2e711aad5
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -79,6 +79,9 @@ class GuidBasedRecommender:
self._redis_cache = AddonsCoinstallCache(self._ctx)
self.logger.info("GUIDBasedRecommender is initialized")
def cache_ready(self):
return self._redis_cache.is_active()
def can_recommend(self, client_data):
# We can't recommend if we don't have our data files.
if not self._redis_cache.is_active():
@ -105,6 +108,9 @@ class GuidBasedRecommender:
TAAR lite will yield 4 recommendations for the AMO page
"""
if not self._redis_cache.is_active():
return []
with log_timer_debug(f"Results computed", self.logger):
with log_timer_debug("get client data", self.logger):