Skip to content

Commit 7660c91

Browse files
Gargronhiyuki2578
authored andcommitted
Fix wrong percentages in admin UI for hashtag usage breakdown (mastodon#11714)
1 parent ae1bb45 commit 7660c91

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

app/controllers/admin/tags_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def set_tag
3737

3838
def set_usage_by_domain
3939
@usage_by_domain = @tag.statuses
40-
.where(visibility: :public)
40+
.with_public_visibility
41+
.excluding_silenced_accounts
4142
.where(Status.arel_table[:id].gteq(Mastodon::Snowflake.id_at(Time.now.utc.beginning_of_day)))
4243
.joins(:account)
4344
.group('accounts.domain')

app/views/admin/tags/show.html.haml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
.table-wrapper
3939
%table.table
4040
%tbody
41+
- total = @usage_by_domain.sum(&:statuses_count).to_f
42+
4143
- @usage_by_domain.each do |(domain, count)|
4244
%tr
4345
%th= domain || site_hostname
44-
%td= number_to_percentage((count / @tag.history[0][:uses].to_f) * 100)
46+
%td= number_to_percentage((count / total) * 100, precision: 1)
4547
%td= number_with_delimiter count

0 commit comments

Comments
 (0)