From 9848a26fa99b76c47139d523eab62a12f9e1430a Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 15 Nov 2017 11:03:33 -0800 Subject: [PATCH] lower threshold to use cosine similarity algo for related tags --- app/models/tag.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index d0efc2281..30fc3cfaf 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,5 +1,5 @@ class Tag < ApplicationRecord - COSINE_SIMILARITY_RELATED_TAG_THRESHOLD = 1000 + COSINE_SIMILARITY_RELATED_TAG_THRESHOLD = 300 METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|parent|-parent|child|pixiv_id|pixiv|search|upvote|downvote|filetype|-filetype|flagger|-flagger|appealer|-appealer|" + TagCategory.short_name_list.map {|x| "#{x}tags"}.join("|") SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm|flagger|-flagger|appealer|-appealer" @@ -754,13 +754,9 @@ class Tag < ApplicationRecord if Cache.get("urt:#{key}").nil? && should_update_related? if post_count < COSINE_SIMILARITY_RELATED_TAG_THRESHOLD delay(:queue => "default").update_related - elsif post_count >= COSINE_SIMILARITY_RELATED_TAG_THRESHOLD - cache_check = Cache.get("urt:#{key}") - - if cache_check - sqs = SqsService.new(Danbooru.config.aws_sqs_reltagcalc_url) - sqs.send_message("calculate #{name}") - end + else + sqs = SqsService.new(Danbooru.config.aws_sqs_reltagcalc_url) + sqs.send_message("calculate #{name}") end Cache.put("urt:#{key}", true, 600) # mutex to prevent redundant updates