reportbooru: raise exception if not configured.
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
# queries reportbooru to find missed post searches
|
# queries reportbooru to find missed post searches
|
||||||
class MissedSearchService
|
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)
|
def each_search(&block)
|
||||||
fetch_data.scan(/(.+?) (\d+)\.0\n/).each(&block)
|
fetch_data.scan(/(.+?) (\d+)\.0\n/).each(&block)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,15 @@
|
|||||||
class PopularSearchService
|
class PopularSearchService
|
||||||
attr_reader :date, :scale
|
attr_reader :date, :scale
|
||||||
|
|
||||||
|
def self.enabled?
|
||||||
|
Danbooru.config.reportbooru_server.present?
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(date, scale)
|
def initialize(date, scale)
|
||||||
|
if !PopularSearchService.enabled?
|
||||||
|
raise NotImplementedError.new("the Reportbooru service isn't configured. Popular searches are not available.")
|
||||||
|
end
|
||||||
|
|
||||||
@date = date
|
@date = date
|
||||||
@scale = scale
|
@scale = scale
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module Reports
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_similar_user_ids(endpoint = "user_similarity")
|
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 = {
|
params = {
|
||||||
"key" => Danbooru.config.reportbooru_key,
|
"key" => Danbooru.config.reportbooru_key,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<li id="secondary-links-posts-upload" class="nonessential"><%= link_to "Upload", new_upload_path %></li>
|
<li id="secondary-links-posts-upload" class="nonessential"><%= link_to "Upload", new_upload_path %></li>
|
||||||
<li id="secondary-links-posts-popular"><%= link_to "Popular", popular_explore_posts_path %></li>
|
<li id="secondary-links-posts-popular"><%= link_to "Popular", popular_explore_posts_path %></li>
|
||||||
<li id="secondary-links-posts-hot"><%= link_to "Hot", posts_path(:tags => "order:rank") %></li>
|
<li id="secondary-links-posts-hot"><%= link_to "Hot", posts_path(:tags => "order:rank") %></li>
|
||||||
<% if Danbooru.config.reportbooru_server %>
|
<% if PopularSearchService.enabled? %>
|
||||||
<li id="secondary-links-posts-searches"><%= link_to "Searches", searches_explore_posts_path %></li>
|
<li id="secondary-links-posts-searches"><%= link_to "Searches", searches_explore_posts_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless CurrentUser.is_anonymous? %>
|
<% unless CurrentUser.is_anonymous? %>
|
||||||
|
|||||||
Reference in New Issue
Block a user