Skip to content

Commit

Permalink
Fix weekly usage not being displayed correctly in hashtag admin UI (m…
Browse files Browse the repository at this point in the history
…astodon#11524)

Fix percentages in usage breakdown having too many digits

Change trending hashtags to only ask for review if a hashtag enters
the top 3 position in the set, since it's the only items shown in
the default web UI
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent 0276a42 commit 63774aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def current_week_days
now = Time.now.utc.beginning_of_day.to_date

(Date.commercial(now.cwyear, now.cweek)..now).map do |date|
date.to_time.utc.beginning_of_day.to_i
date.to_time(:utc).beginning_of_day.to_i
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/trending_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class TrendingTags
EXPIRE_TRENDS_AFTER = 1.day.seconds
THRESHOLD = 5
LIMIT = 10
REVIEW_THRESHOLD = 3

class << self
include Redisable
Expand Down Expand Up @@ -60,7 +61,7 @@ def increment_vote!(tag, at_time)
old_rank = redis.zrevrank(key, tag.id)

redis.zadd(key, score, tag.id)
request_review!(tag) if (old_rank.nil? || old_rank > LIMIT) && redis.zrevrank(key, tag.id) <= LIMIT && !tag.trendable? && tag.requires_review? && !tag.requested_review?
request_review!(tag) if (old_rank.nil? || old_rank > REVIEW_THRESHOLD) && redis.zrevrank(key, tag.id) <= REVIEW_THRESHOLD && !tag.trendable? && tag.requires_review? && !tag.requested_review?
end

redis.expire(key, EXPIRE_TRENDS_AFTER)
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tags/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
- @usage_by_domain.each do |(domain, count)|
%tr
%th= domain || site_hostname
%td= "#{number_with_delimiter((count.to_f / @tag.history[0][:uses].to_f) * 100)}%"
%td= number_to_percentage((count / @tag.history[0][:uses].to_f) * 100)
%td= number_with_delimiter count

0 comments on commit 63774aa

Please sign in to comment.