reduce redundant sqs calls for updating related tags

This commit is contained in:
r888888888 2016-01-12 11:26:39 -08:00
parent a575891cec
commit 21842996d4
2 changed files with 12 additions and 2 deletions

View File

@ -384,3 +384,6 @@ DEPENDENCIES
vcr
webmock
whenever
BUNDLED WITH
1.10.0

View File

@ -626,8 +626,15 @@ class Tag < ActiveRecord::Base
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_reltagcalc_url)
sqs.send_message("calculate #{name}")
key = Cache.sanitize(name)
cache_check = Cache.get("urt:#{key}")
if cache_check
sqs = SqsService.new(Danbooru.config.aws_sqs_reltagcalc_url)
sqs.send_message("calculate #{name}")
else
Cache.put("urt:#{key}", true, 600)
end
end
end
end