for high post count tags use cosine similarity to calculate related tags
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
class Tag < ActiveRecord::Base
|
||||
COSINE_SIMILARITY_RELATED_TAG_THRESHOLD = 100_000
|
||||
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|sub|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|-parent|child|pixiv_id|pixiv|search"
|
||||
SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm"
|
||||
attr_accessible :category, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||
@@ -621,8 +622,13 @@ class Tag < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def update_related_if_outdated
|
||||
if should_update_related? && Delayed::Job.count < 200
|
||||
delay(:queue => "default").update_related
|
||||
if should_update_related?
|
||||
if post_count < COSINE_SIMILARITY_RELATED_TAG_THRESHOLD && Delayed::Job.count < 200
|
||||
delay(:queue => "default").update_related
|
||||
elsif post_count >= COSINE_SIMILARITY_RELATED_TAG_THRESHOLD
|
||||
sqs = SqsService.new(Danbooru.config.aws_sqs_queue_reltagcalc_url)
|
||||
sqs.send_message("calculate #{name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -431,6 +431,9 @@ module Danbooru
|
||||
def aws_sqs_queue_url
|
||||
end
|
||||
|
||||
def aws_sqs_queue_reltagcalc_url
|
||||
end
|
||||
|
||||
def aws_sqs_region
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user