latest attempt to fix search timeout bug

This commit is contained in:
Kyle Drake 2025-01-16 14:11:54 -06:00
parent 92902696ab
commit f3a2116b6e

View file

@ -120,10 +120,8 @@ def browse_sites_dataset
end end
def daily_search_max? def daily_search_max?
query_count = $redis_cache.get("search_query_count").to_i query_count = $redis_cache.get('search_query_count').to_i
$redis_cache.expire("search_query_count", 86400) if query_count == 0 query_count >= $config['google_custom_search_query_limit']
return true if query_count >= $config['google_custom_search_query_limit']
false
end end
get '/browse/search' do get '/browse/search' do
@ -136,7 +134,8 @@ get '/browse/search' do
end end
if !params[:q].blank? 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 = params[:start].to_i
@start = 0 if @start < 0 @start = 0 if @start < 0