#251 ニコニコ同期にて “ニコニコ” および “動画” を自動付与するやぅに(#156)

Merged
みてるぞ merged 1 commits from feature/156 into main 1 week ago
  1. +8
    -0
      backend/app/models/tag.rb
  2. +1
    -1
      backend/lib/tasks/sync_nico.rake

+ 8
- 0
backend/app/models/tag.rb View File

@@ -67,6 +67,14 @@ class Tag < ApplicationRecord
@bot ||= find_or_create_by_tag_name!('bot操作', category: :meta)
end

def self.video
@video ||= find_or_create_by_tag_name!('動画', category: :meta)
end

def self.niconico
@niconico ||= find_or_create_by_tag_name!('ニコニコ', category: :meta)
end

def self.normalise_tags tag_names, with_tagme: true, deny_nico: true
if deny_nico && tag_names.any? { |n| n.start_with?('nico:') }
raise NicoTagNormalisationError


+ 1
- 1
backend/lib/tasks/sync_nico.rake View File

@@ -91,7 +91,7 @@ namespace :nico do
end
post.save!
post.resized_thumbnail!
sync_post_tags!(post, [Tag.tagme.id])
sync_post_tags!(post, [Tag.tagme.id, Tag.bot.id, Tag.niconico.id, Tag.video.id])
end

kept_ids = PostTag.kept.where(post_id: post.id).pluck(:tag_id).to_set


Loading…
Cancel
Save