FIX: global setting needs to be coerced to float (#11162)

disable_search_queue_threshold needs to be coerced to a float so it is not
treated as a string when sub second values are provided.

Longer term fix is to possibly provide hints in the config so we do the
coersion automatically. However this would be a far more complex change.
This commit is contained in:
Sam 2020-11-09 16:46:52 +11:00 committed by GitHub
parent 1455421433
commit 94cd5ac0b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -173,9 +173,13 @@ class SearchController < ApplicationController
protected
def site_overloaded?
(queue_time = request.env['REQUEST_QUEUE_SECONDS']) &&
(GlobalSetting.disable_search_queue_threshold > 0) &&
(queue_time > GlobalSetting.disable_search_queue_threshold)
queue_time = request.env['REQUEST_QUEUE_SECONDS']
if queue_time
threshold = GlobalSetting.disable_search_queue_threshold.to_f
threshold > 0 && queue_time > threshold
else
false
end
end
def rate_limit_search