track searches that return no results
This commit is contained in:
22
app/logical/missed_search_service.rb
Normal file
22
app/logical/missed_search_service.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# queries reportbooru to find missed post searches
|
||||
class MissedSearchService
|
||||
def each_search(&block)
|
||||
fetch_data.scan(/(.+?) (\d+)\.0\n/).each(&block)
|
||||
end
|
||||
|
||||
def fetch_data
|
||||
# Cache.get("ms", 1.minute) do
|
||||
url = URI.parse("#{Danbooru.config.report_server}/missed_searches")
|
||||
response = ""
|
||||
Net::HTTP.start(url.host, url.port, :use_ssl => url.is_a?(URI::HTTPS)) do |http|
|
||||
http.read_timeout = 1
|
||||
http.request_get(url.request_uri) do |res|
|
||||
if res.is_a?(Net::HTTPSuccess)
|
||||
response = res.body
|
||||
end
|
||||
end
|
||||
end
|
||||
response
|
||||
# end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user