feat: “ニジラー情報不詳” タグの自動付与(#106) #196

マージ済み
みてるぞ が 9 個のコミットを '#106' から main へマージ 2026-03-07 13:58:44 +09:00
2個のファイルの変更8行の追加0行の削除
コミット 9f10bc8467 の変更だけを表示してゐます - すべてのコミットを表示
+7
ファイルの表示
@@ -46,6 +46,12 @@ class Tag < ApplicationRecord
end end
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 def self.normalise_tags tag_names, with_tagme: true
tags = tag_names.map do |name| tags = tag_names.map do |name|
pf, cat = CATEGORY_PREFIXES.find { |p, _| name.start_with?(p) } || ['', nil] pf, cat = CATEGORY_PREFIXES.find { |p, _| name.start_with?(p) } || ['', nil]
@@ -58,6 +64,7 @@ class Tag < ApplicationRecord
end end
end end
tags << Tag.tagme if with_tagme && tags.size < 20 && tags.none?(Tag.tagme) 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 tags.uniq
end end
+1
ファイルの表示
@@ -53,6 +53,7 @@ namespace :nico do
end end
tags_to_add << Tag.tagme if post.tags.size < 20 tags_to_add << Tag.tagme if post.tags.size < 20
tags_to_add << Tag.bot tags_to_add << Tag.bot
tags_to_add << Tag.no_deerjikist if post.tags.all? { |t| t.category != 'deerjikist' }
post.tags = (post.tags + tags_to_add).uniq post.tags = (post.tags + tags_to_add).uniq
end end
end end