reportbooru: decrease http timeout, increase cache length.
Decrease the HTTP timeout to 0.5 seconds when fetching popular tags from Reportbooru. Increase the length of time that popular tags are cached from 1 minute to 1 hour. This is for the list of popular searches in the front page sidebar.
This commit is contained in:
@@ -3,7 +3,7 @@ class ReportbooruService
|
|||||||
|
|
||||||
def initialize(http: Danbooru::Http.new, reportbooru_server: Danbooru.config.reportbooru_server)
|
def initialize(http: Danbooru::Http.new, reportbooru_server: Danbooru.config.reportbooru_server)
|
||||||
@reportbooru_server = reportbooru_server
|
@reportbooru_server = reportbooru_server
|
||||||
@http = http
|
@http = http.timeout(0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enabled?
|
def enabled?
|
||||||
@@ -28,9 +28,9 @@ class ReportbooruService
|
|||||||
request("#{reportbooru_server}/post_views/rank?date=#{date}", expires_in)
|
request("#{reportbooru_server}/post_views/rank?date=#{date}", expires_in)
|
||||||
end
|
end
|
||||||
|
|
||||||
def popular_searches(date, limit: 100)
|
def popular_searches(date, limit: 100, expires_in: 1.hour)
|
||||||
ranking = post_search_rankings(date)
|
ranking = post_search_rankings(date, expires_in: expires_in)
|
||||||
ranking = post_search_rankings(date.yesterday) if ranking.blank?
|
ranking = post_search_rankings(date.yesterday, expires_in: expires_in) if ranking.blank?
|
||||||
ranking.take(limit).map(&:first)
|
ranking.take(limit).map(&:first)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user