Parcourir la source

Update SuggestionService

Daniel Supernault il y a 6 ans
Parent
commit
c7d97bb864
1 fichiers modifiés avec 8 ajouts et 1 suppressions
  1. 8 1
      app/Services/SuggestionService.php

+ 8 - 1
app/Services/SuggestionService.php

@@ -34,9 +34,14 @@ class SuggestionService {
 		return self::del($val);
 		return self::del($val);
 	}
 	}
 
 
+	public static function count()
+	{
+		return Redis::zcount(self::CACHE_KEY, '-inf', '+inf');
+	}
+
 	public static function warmCache($force = false)
 	public static function warmCache($force = false)
 	{
 	{
-		if(Redis::zcount(self::CACHE_KEY, '-inf', '+inf') == 0 || $force == true) {
+		if(self::count() == 0 || $force == true) {
 			$ids = Profile::whereNull('domain')
 			$ids = Profile::whereNull('domain')
 				->whereIsSuggestable(true)
 				->whereIsSuggestable(true)
 				->whereIsPrivate(false)
 				->whereIsPrivate(false)
@@ -44,6 +49,8 @@ class SuggestionService {
 			foreach($ids as $id) {
 			foreach($ids as $id) {
 				self::set($id);
 				self::set($id);
 			}
 			}
+			return 1;
 		}
 		}
+		return 0;
 	}
 	}
 }
 }