tweak trending algorithm
This commit is contained in:
@@ -118,17 +118,17 @@ class Tag < ActiveRecord::Base
|
|||||||
|
|
||||||
module StatisticsMethods
|
module StatisticsMethods
|
||||||
def trending_count_limit
|
def trending_count_limit
|
||||||
20
|
10
|
||||||
end
|
end
|
||||||
|
|
||||||
def trending
|
def trending
|
||||||
Cache.get("popular-tags-v2", 1.hour) do
|
Cache.get("popular-tags-v3", 1.hour) do
|
||||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||||
n = 3
|
n = 8
|
||||||
counts = {}
|
counts = {}
|
||||||
|
|
||||||
while counts.empty? && n < 256
|
while counts.empty? && n < 256
|
||||||
tag_strings = Post.select_values_sql("select tag_string from posts where created_at >= ? order by md5 limit 100", n.days.ago)
|
tag_strings = Post.select_values_sql("select tag_string from posts where created_at >= ?", n.hours.ago)
|
||||||
tag_strings.each do |tag_string|
|
tag_strings.each do |tag_string|
|
||||||
tag_string.scan(/\S+/).each do |tag|
|
tag_string.scan(/\S+/).each do |tag|
|
||||||
counts[tag] ||= 0
|
counts[tag] ||= 0
|
||||||
@@ -144,7 +144,7 @@ class Tag < ActiveRecord::Base
|
|||||||
[tag_name, recent_count.to_f / tag.post_count.to_f]
|
[tag_name, recent_count.to_f / tag.post_count.to_f]
|
||||||
end
|
end
|
||||||
|
|
||||||
counts.sort_by {|x| -x[1]}.slice(0, 20).map(&:first)
|
counts.sort_by {|x| -x[1]}.slice(0, 25).map(&:first)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Danbooru
|
|||||||
class Configuration
|
class Configuration
|
||||||
# The version of this Danbooru.
|
# The version of this Danbooru.
|
||||||
def version
|
def version
|
||||||
"2.22.1"
|
"2.22.2"
|
||||||
end
|
end
|
||||||
|
|
||||||
# The name of this Danbooru.
|
# The name of this Danbooru.
|
||||||
|
|||||||
Reference in New Issue
Block a user