diff --git a/README.md b/README.md index c555459ad..f0341f343 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,6 @@ The following features are delegated to the [Reportbooru service](https://github * Popular searches report * Favorite searches * Upload trend graphs -* Similar users (via favorites and post votes) ### Recommender Service diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index e3fdb95d8..bef3f9fe7 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,17 +1,11 @@ class ReportsController < ApplicationController before_action :member_only, :except => [:upload_tags] - before_action :gold_only, :only => [:similar_users] before_action :moderator_only, :only => [:post_versions, :post_versions_create, :down_voting_post_report, :down_voting_post_report_create] def uploads @report = Reports::Uploads.new(params[:min_date], params[:max_date], params[:queries]) end - def similar_users - @report = Reports::UserSimilarity.new(CurrentUser.id) - @presenter = UserSimilarityPresenter.new(@report) - end - def post_versions end diff --git a/app/javascript/src/styles/specific/reports.scss b/app/javascript/src/styles/specific/reports.scss index 406ae6031..e69de29bb 100644 --- a/app/javascript/src/styles/specific/reports.scss +++ b/app/javascript/src/styles/specific/reports.scss @@ -1,25 +0,0 @@ -#c-reports { - #a-similar-users { - div.box { - h2, h3 { - color: #333; - } - - margin-bottom: 2em; - } - - span.accuracy { - color: #666; - } - - /* clearfix hacks */ - div.box:before, div.box:after { - content: ""; - display: table; - } - - div.box:after { - clear: both; - } - } -} \ No newline at end of file diff --git a/app/logical/reports/user_similarity.rb b/app/logical/reports/user_similarity.rb deleted file mode 100644 index 6f439aff4..000000000 --- a/app/logical/reports/user_similarity.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Reports - class UserSimilarity - NOT_READY_STRING = "not ready" - - attr_reader :user_id, :result - - def initialize(user_id) - @user_id = user_id - end - - def user - User.find(user_id) - end - - def prime(endpoint = "user_similarity") - 10.times do - @result = fetch_similar_user_ids(endpoint) - if @result == NOT_READY_STRING - sleep(60) - else - break - end - end - end - - def fetch_similar_user_ids(endpoint = "user_similarity") - 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, - "user_id" => user_id - } - uri = URI.parse("#{Danbooru.config.reportbooru_server}/reports/#{endpoint}") - uri.query = URI.encode_www_form(params) - - resp = HTTParty.get(uri, Danbooru.config.httparty_options) - if resp.success? - resp.body - else - raise "HTTP error code: #{resp.code} #{resp.message}" - end - end - end -end diff --git a/app/presenters/user_similarity_presenter.rb b/app/presenters/user_similarity_presenter.rb deleted file mode 100644 index 8afd6c5b9..000000000 --- a/app/presenters/user_similarity_presenter.rb +++ /dev/null @@ -1,48 +0,0 @@ -class UserSimilarityPresenter - attr_reader :report, :user_ids, :user_ids_with_scores, :not_ready - - def initialize(report) - @report = report - fetch - end - - def not_ready? - not_ready - end - - def insufficient_data? - report.user.favorite_count < 200 - end - - def fetch - data = report.fetch_similar_user_ids - - if data == Reports::UserSimilarity::NOT_READY_STRING - @not_ready = true - else - @user_ids_with_scores = data.scan(/\S+/).in_groups_of(2) - end - end - - def user_ids - user_ids_with_scores.map(&:first) - end - - def scores - user_ids_with_scores.map(&:last) - end - - def each_user(&block) - user_ids_with_scores.each do |user_id, score| - user = User.find(user_id) - - if !user.hide_favorites? - yield(user, 100 * score.to_f) - end - end - end - - def each_favorite_for(user, &block) - user.favorites.limit(18).joins(:post).reorder("favorites.id desc").map(&:post).each(&block) - end -end diff --git a/app/views/favorites/index.html.erb b/app/views/favorites/index.html.erb index d6d14518e..57d41aa46 100644 --- a/app/views/favorites/index.html.erb +++ b/app/views/favorites/index.html.erb @@ -15,10 +15,6 @@