Fix #3639: Favorite count pixiv tags aren't skipped by translated tags.
This commit is contained in:
@@ -83,6 +83,8 @@ module Sources
|
||||
|
||||
# Given a tag from the source site, should return an array of corresponding Danbooru tags.
|
||||
def translate_tag(untranslated_tag)
|
||||
return [] if untranslated_tag.blank?
|
||||
|
||||
translated_tag_names = WikiPage.active.other_names_equal(untranslated_tag).uniq.pluck(:title)
|
||||
translated_tag_names = TagAlias.to_aliased(translated_tag_names)
|
||||
translated_tags = Tag.where(name: translated_tag_names)
|
||||
|
||||
@@ -57,7 +57,7 @@ module Sources
|
||||
end
|
||||
|
||||
def translate_tag(tag)
|
||||
normalized_tag = tag.gsub(/\A(\S+?)_?\d+users入り\Z/i, '\1')
|
||||
normalized_tag = tag.gsub(/\d+users入り\z/i, "")
|
||||
|
||||
translated_tags = super(normalized_tag)
|
||||
if translated_tags.empty? && normalized_tag.include?("/")
|
||||
|
||||
@@ -228,6 +228,15 @@ module Sources
|
||||
|
||||
assert_equal([toosaka_rin], @site.translate_tag("遠坂凛"))
|
||||
end
|
||||
|
||||
should "not translate '1000users入り' to '1'" do
|
||||
FactoryBot.create(:tag, name: "1", post_count: 1)
|
||||
source = get_source("https://www.pixiv.net/member_illust.php?mode=medium&illust_id=60665428")
|
||||
tags = %w[Fate/GrandOrder グランブルーファンタジー 手袋 1000users入り]
|
||||
|
||||
assert_equal(tags.sort, source.tags.map(&:first).sort)
|
||||
assert_equal(["fate/grand_order"], source.translated_tags.map(&:first))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user