about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-09-01 19:44:05 +0200
committerGitHub <noreply@github.com>2019-09-01 19:44:05 +0200
commit47584180d8ed03666d45f423107d3113cc4a6230 (patch)
tree662b09b9b111146dcbdad40120c69386773168b5 /app
parentd3442894310022062debc4c6ed6b117f8bc3904b (diff)
Fix wrong percentages in admin UI for hashtag usage breakdown (#11714)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/tags_controller.rb3
-rw-r--r--app/views/admin/tags/show.html.haml4
2 files changed, 5 insertions, 2 deletions
diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb
index 39aca2a4b..25d9b7d3d 100644
--- a/app/controllers/admin/tags_controller.rb
+++ b/app/controllers/admin/tags_controller.rb
@@ -37,7 +37,8 @@ module Admin
 
     def set_usage_by_domain
       @usage_by_domain = @tag.statuses
-                             .where(visibility: :public)
+                             .with_public_visibility
+                             .excluding_silenced_accounts
                              .where(Status.arel_table[:id].gteq(Mastodon::Snowflake.id_at(Time.now.utc.beginning_of_day)))
                              .joins(:account)
                              .group('accounts.domain')
diff --git a/app/views/admin/tags/show.html.haml b/app/views/admin/tags/show.html.haml
index c3779d48c..f9677874a 100644
--- a/app/views/admin/tags/show.html.haml
+++ b/app/views/admin/tags/show.html.haml
@@ -38,8 +38,10 @@
 .table-wrapper
   %table.table
     %tbody
+      - total = @usage_by_domain.sum(&:statuses_count).to_f
+
       - @usage_by_domain.each do |(domain, count)|
         %tr
           %th= domain || site_hostname
-          %td= number_to_percentage((count / @tag.history[0][:uses].to_f) * 100)
+          %td= number_to_percentage((count / total) * 100, precision: 1)
           %td= number_with_delimiter count