forked from e621ng/e621ng
reduce redundant sqs calls for updating related tags
This commit is contained in:
parent
a575891cec
commit
21842996d4
@ -384,3 +384,6 @@ DEPENDENCIES
|
|||||||
vcr
|
vcr
|
||||||
webmock
|
webmock
|
||||||
whenever
|
whenever
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
1.10.0
|
||||||
|
@ -626,8 +626,15 @@ class Tag < ActiveRecord::Base
|
|||||||
if post_count < COSINE_SIMILARITY_RELATED_TAG_THRESHOLD && Delayed::Job.count < 200
|
if post_count < COSINE_SIMILARITY_RELATED_TAG_THRESHOLD && Delayed::Job.count < 200
|
||||||
delay(:queue => "default").update_related
|
delay(:queue => "default").update_related
|
||||||
elsif post_count >= COSINE_SIMILARITY_RELATED_TAG_THRESHOLD
|
elsif post_count >= COSINE_SIMILARITY_RELATED_TAG_THRESHOLD
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_reltagcalc_url)
|
key = Cache.sanitize(name)
|
||||||
sqs.send_message("calculate #{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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user