about summary refs log tree commit diff
path: root/app/models/trending_tags.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-06-04 02:18:18 +0200
committerGitHub <noreply@github.com>2018-06-04 02:18:18 +0200
commit0deb9fa6b9b8820fcb0a9ebd221178a8ec82490a (patch)
tree8d41e4f356c41e74ea2b1d5c0b0552b058d7495a /app/models/trending_tags.rb
parent00512ecf87e1098f5632eeec2cd116344a787523 (diff)
Remove trending hashtags (#7711)
* Delete trends_controller.rb

* Update routes.rb

* Update trending_tags.rb

* Update index.js

* Update index.js

* Update search_results.js

* Update async-components.js

* Update index.js

* Delete trends.js

* Delete trends.js

* Delete trends_container.js

* Delete trends.js

* Update search_results.js

* Update search_results_container.js
Diffstat (limited to 'app/models/trending_tags.rb')
-rw-r--r--app/models/trending_tags.rb22
1 files changed, 0 insertions, 22 deletions
diff --git a/app/models/trending_tags.rb b/app/models/trending_tags.rb
index 287de2a8a..c3641d7fd 100644
--- a/app/models/trending_tags.rb
+++ b/app/models/trending_tags.rb
@@ -1,9 +1,7 @@
 # frozen_string_literal: true
 
 class TrendingTags
-  KEY                  = 'trending_tags'
   EXPIRE_HISTORY_AFTER = 7.days.seconds
-  THRESHOLD            = 5
 
   class << self
     def record_use!(tag, account, at_time = Time.now.utc)
@@ -11,30 +9,10 @@ class TrendingTags
 
       increment_historical_use!(tag.id, at_time)
       increment_unique_use!(tag.id, account.id, at_time)
-      increment_vote!(tag.id, at_time)
-    end
-
-    def get(limit)
-      tag_ids = redis.zrevrange(KEY, 0, limit).map(&:to_i)
-      tags    = Tag.where(id: tag_ids).to_a.map { |tag| [tag.id, tag] }.to_h
-      tag_ids.map { |tag_id| tags[tag_id] }.compact
     end
 
     private
 
-    def increment_vote!(tag_id, at_time)
-      expected = redis.pfcount("activity:tags:#{tag_id}:#{(at_time - 1.day).beginning_of_day.to_i}:accounts").to_f
-      expected = 1.0 if expected.zero?
-      observed = redis.pfcount("activity:tags:#{tag_id}:#{at_time.beginning_of_day.to_i}:accounts").to_f
-
-      if expected > observed || observed < THRESHOLD
-        redis.zrem(KEY, tag_id.to_s)
-      else
-        score = ((observed - expected)**2) / expected
-        redis.zadd(KEY, score, tag_id.to_s)
-      end
-    end
-
     def increment_historical_use!(tag_id, at_time)
       key = "activity:tags:#{tag_id}:#{at_time.beginning_of_day.to_i}"
       redis.incrby(key, 1)