|
|
@@ -98,7 +98,9 @@ class Tag < ApplicationRecord |
|
|
@niconico ||= find_or_create_by_tag_name!('ニコニコ', category: :meta) |
|
|
@niconico ||= find_or_create_by_tag_name!('ニコニコ', category: :meta) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def self.normalise_tags tag_names, with_tagme: true, deny_nico: true |
|
|
|
|
|
|
|
|
def self.normalise_tags tag_names, with_tagme: true, |
|
|
|
|
|
with_no_deerjikist: true, |
|
|
|
|
|
deny_nico: true |
|
|
if deny_nico && tag_names.any? { |n| n.downcase.start_with?('nico:') } |
|
|
if deny_nico && tag_names.any? { |n| n.downcase.start_with?('nico:') } |
|
|
raise NicoTagNormalisationError |
|
|
raise NicoTagNormalisationError |
|
|
end |
|
|
end |
|
|
@@ -112,7 +114,7 @@ class Tag < ApplicationRecord |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme) |
|
|
tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme) |
|
|
tags << Tag.no_deerjikist if tags.all? { |t| !(t.deerjikist?) } |
|
|
|
|
|
|
|
|
tags << Tag.no_deerjikist if with_no_deerjikist && tags.all? { |t| !(t.deerjikist?) } |
|
|
tags.uniq(&:id) |
|
|
tags.uniq(&:id) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|