From f3a2116b6e6e67233aed442949eae343ed227d32 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Thu, 16 Jan 2025 14:11:54 -0600 Subject: [PATCH] latest attempt to fix search timeout bug --- app/browse.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/browse.rb b/app/browse.rb index 29d8f7b9..8487fdc3 100644 --- a/app/browse.rb +++ b/app/browse.rb @@ -120,10 +120,8 @@ def browse_sites_dataset end def daily_search_max? - query_count = $redis_cache.get("search_query_count").to_i - $redis_cache.expire("search_query_count", 86400) if query_count == 0 - return true if query_count >= $config['google_custom_search_query_limit'] - false + query_count = $redis_cache.get('search_query_count').to_i + query_count >= $config['google_custom_search_query_limit'] end get '/browse/search' do @@ -136,7 +134,8 @@ get '/browse/search' do end if !params[:q].blank? - $redis_cache.incr("search_query_count") + created = $redis_cache.set('search_query_count', 1, nx: true, ex: 86400) + $redis_cache.incr('search_query_count') unless created @start = params[:start].to_i @start = 0 if @start < 0