From c7c9ef19402970ec612d4e657a4f4eb10d871dc6 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Mon, 1 Jul 2013 01:27:51 -0700 Subject: [PATCH] tweak trending algorithm --- app/models/tag.rb | 10 +++++----- config/danbooru_default_config.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index e48591318..baa234c7c 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -118,17 +118,17 @@ class Tag < ActiveRecord::Base module StatisticsMethods def trending_count_limit - 20 + 10 end 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 - n = 3 + n = 8 counts = {} 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_string.scan(/\S+/).each do |tag| counts[tag] ||= 0 @@ -144,7 +144,7 @@ class Tag < ActiveRecord::Base [tag_name, recent_count.to_f / tag.post_count.to_f] 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 diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index dcc731242..f195d796f 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -4,7 +4,7 @@ module Danbooru class Configuration # The version of this Danbooru. def version - "2.22.1" + "2.22.2" end # The name of this Danbooru.