From 427720060eda5a2058c292a3b21b52b600ee2072 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 21:02:15 -0600 Subject: [PATCH 1/2] Update ApiController --- app/Http/Controllers/ApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 5d5a46405..e54083d94 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -75,7 +75,7 @@ class ApiController extends BaseApiController ->whereNull('status') ->whereNull('domain') ->inRandomOrder() - ->take(4) + ->take(3) ->get() ->map(function($item, $key) { return [ From c7d97bb8640377992a21dd8d37959bdee051623a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 21:04:42 -0600 Subject: [PATCH 2/2] Update SuggestionService --- app/Services/SuggestionService.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Services/SuggestionService.php b/app/Services/SuggestionService.php index 37a8dff33..9160b0472 100644 --- a/app/Services/SuggestionService.php +++ b/app/Services/SuggestionService.php @@ -34,9 +34,14 @@ class SuggestionService { return self::del($val); } + public static function count() + { + return Redis::zcount(self::CACHE_KEY, '-inf', '+inf'); + } + 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') ->whereIsSuggestable(true) ->whereIsPrivate(false) @@ -44,6 +49,8 @@ class SuggestionService { foreach($ids as $id) { self::set($id); } + return 1; } + return 0; } } \ No newline at end of file