diff --git a/app/assets/stylesheets/specific/reports.css.scss b/app/assets/stylesheets/specific/reports.css.scss index f7c6bf5d2..406ae6031 100644 --- a/app/assets/stylesheets/specific/reports.css.scss +++ b/app/assets/stylesheets/specific/reports.css.scss @@ -8,6 +8,10 @@ margin-bottom: 2em; } + span.accuracy { + color: #666; + } + /* clearfix hacks */ div.box:before, div.box:after { content: ""; diff --git a/app/presenters/user_similarity_presenter.rb b/app/presenters/user_similarity_presenter.rb index 9d5e6013d..5c820d386 100644 --- a/app/presenters/user_similarity_presenter.rb +++ b/app/presenters/user_similarity_presenter.rb @@ -1,5 +1,5 @@ class UserSimilarityPresenter - attr_reader :report, :user_ids, :not_ready + attr_reader :report, :user_ids, :user_ids_with_scores, :not_ready def initialize(report) @report = report @@ -11,21 +11,31 @@ class UserSimilarityPresenter end def insufficient_data? - report.user.favorite_count < 500 + report.user.favorite_count < 300 end def fetch - user_ids = report.fetch_similar_user_ids + data = report.fetch_similar_user_ids - if user_ids == "not ready" + if data == "not ready" @not_ready = true else - @user_ids = user_ids.scan(/\d+/).slice(0, 10) + @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.where(id: user_ids).each(&block) + user_ids_with_scores.each do |user_id, score| + yield(User.find(user_id), 100 * score.to_f) + end end def each_favorite_for(user, &block) diff --git a/app/views/reports/similar_users.html.erb b/app/views/reports/similar_users.html.erb index d07b7d389..ec55ba178 100644 --- a/app/views/reports/similar_users.html.erb +++ b/app/views/reports/similar_users.html.erb @@ -3,15 +3,15 @@
You need at least 500 favorites before Danbooru can calculate users similar to you.
+You need at least 300 favorites before Danbooru can calculate users similar to you.
<% elsif @presenter.not_ready? %>The report is still being generated. Check back in a few minutes.
<% else %> - <% @presenter.each_user do |user| %> + <% @presenter.each_user do |user, score| %>