reportbooru: raise exception if not configured.
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
# queries reportbooru to find missed post searches
|
||||
class MissedSearchService
|
||||
def self.enabled?
|
||||
Danbooru.config.reportbooru_server.present?
|
||||
end
|
||||
|
||||
def initialize
|
||||
if !MissedSearchService.enabled?
|
||||
raise NotImplementedError.new("the Reportbooru service isn't configured. Missed searches are not available.")
|
||||
end
|
||||
end
|
||||
|
||||
def each_search(&block)
|
||||
fetch_data.scan(/(.+?) (\d+)\.0\n/).each(&block)
|
||||
end
|
||||
|
||||
@@ -2,7 +2,15 @@
|
||||
class PopularSearchService
|
||||
attr_reader :date, :scale
|
||||
|
||||
def self.enabled?
|
||||
Danbooru.config.reportbooru_server.present?
|
||||
end
|
||||
|
||||
def initialize(date, scale)
|
||||
if !PopularSearchService.enabled?
|
||||
raise NotImplementedError.new("the Reportbooru service isn't configured. Popular searches are not available.")
|
||||
end
|
||||
|
||||
@date = date
|
||||
@scale = scale
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ module Reports
|
||||
end
|
||||
|
||||
def fetch_similar_user_ids(endpoint = "user_similarity")
|
||||
return NotImplementedError unless Danbooru.config.reportbooru_server
|
||||
raise NotImplementedError.new("the Reportbooru service isn't configured. User similarity is not available.") unless Danbooru.config.reportbooru_server
|
||||
|
||||
params = {
|
||||
"key" => Danbooru.config.reportbooru_key,
|
||||
|
||||
Reference in New Issue
Block a user