Fix wrong percentages in admin UI for hashtag usage breakdown (#11714)

This commit is contained in:
Eugen Rochko 2019-09-01 19:44:05 +02:00 committed by GitHub
parent d344289431
commit 47584180d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -37,7 +37,8 @@ module Admin
def set_usage_by_domain def set_usage_by_domain
@usage_by_domain = @tag.statuses @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))) .where(Status.arel_table[:id].gteq(Mastodon::Snowflake.id_at(Time.now.utc.beginning_of_day)))
.joins(:account) .joins(:account)
.group('accounts.domain') .group('accounts.domain')

View File

@ -38,8 +38,10 @@
.table-wrapper .table-wrapper
%table.table %table.table
%tbody %tbody
- total = @usage_by_domain.sum(&:statuses_count).to_f
- @usage_by_domain.each do |(domain, count)| - @usage_by_domain.each do |(domain, count)|
%tr %tr
%th= domain || site_hostname %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 %td= number_with_delimiter count