|
|
@@ -46,6 +46,12 @@ class Tag < ApplicationRecord |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def self.no_deerjikist |
|
|
|
@no_deerjikist ||= Tag.find_or_initialize_by(name: 'ニジラー情報なし') do |tag| |
|
|
|
tag.category = 'meta' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def self.normalise_tags tag_names, with_tagme: true |
|
|
|
tags = tag_names.map do |name| |
|
|
|
pf, cat = CATEGORY_PREFIXES.find { |p, _| name.start_with?(p) } || ['', nil] |
|
|
@@ -58,6 +64,7 @@ class Tag < ApplicationRecord |
|
|
|
end |
|
|
|
end |
|
|
|
tags << Tag.tagme if with_tagme && tags.size < 20 && tags.none?(Tag.tagme) |
|
|
|
tags << Tag.no_deerjikist if tags.all? { |t| t.category != 'deerjika' } |
|
|
|
tags.uniq |
|
|
|
end |
|
|
|
|
|
|
|