default tag listing now weighted by time
This commit is contained in:
@@ -117,9 +117,6 @@ class Tag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
module StatisticsMethods
|
module StatisticsMethods
|
||||||
def trending
|
|
||||||
raise NotImplementedError
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module NameMethods
|
module NameMethods
|
||||||
|
|||||||
@@ -23,16 +23,25 @@ module PostSetPresenters
|
|||||||
end
|
end
|
||||||
|
|
||||||
def popular_tags
|
def popular_tags
|
||||||
n = 1
|
Cache.get("popular-tags", 1.hour) do
|
||||||
results = []
|
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||||
|
n = 1
|
||||||
|
results = []
|
||||||
|
|
||||||
while results.empty? && n < 256
|
while results.empty? && n < 256
|
||||||
query = n.days.ago.strftime("date:>%Y-%m-%d")
|
query = n.days.ago.strftime("date:>%Y-%m-%d")
|
||||||
results = RelatedTagCalculator.calculate_from_sample_to_array(query).map(&:first)
|
results = RelatedTagCalculator.calculate_from_sample_to_array(query)
|
||||||
n *= 2
|
n *= 2
|
||||||
|
end
|
||||||
|
|
||||||
|
results.map! do |tag_name, recent_count|
|
||||||
|
tag = Tag.find_or_create_by_name(tag_name)
|
||||||
|
[tag_name, recent_count.to_f / tag.post_count.to_f]
|
||||||
|
end
|
||||||
|
|
||||||
|
results.sort_by! {|x| -x[1]}.map(&:first)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
results
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pattern_tags
|
def pattern_tags
|
||||||
|
|||||||
Reference in New Issue
Block a user