#282 タグ統合サービスの作成

Closed
opened 2 weeks ago by みてるぞ · 0 comments
def self.merge_tags target_tag, source_tags
  target_tag => Tag

  Tag.transaction do
    Array(source_tags).compact.uniq.each do |st|
      st => Tag
  
      next if st == target_tag

      st.post_tags.find_each do |pt|
        begin
          pt.update!(tag: target_tag)
        rescue ActiveRecord::RecordNotUnique
          pt.discard_by!(nil)
        end
      end

      tag_name = st.tag_name
      st.destroy!
      tag_name.update!(canonical: target_tag.tag_name)
    end
  end
  
  target_tag
end
```ruby def self.merge_tags target_tag, source_tags target_tag => Tag Tag.transaction do   Array(source_tags).compact.uniq.each do |st|     st => Tag     next if st == target_tag     st.post_tags.find_each do |pt|       begin         pt.update!(tag: target_tag) rescue ActiveRecord::RecordNotUnique         pt.discard_by!(nil)       end   end     tag_name = st.tag_name     st.destroy!     tag_name.update!(canonical: target_tag.tag_name)   end end target_tag end
みてるぞ added the
area/backend
label 2 weeks ago
みてるぞ added the
type/enhancement
label 2 weeks ago
みてるぞ added the
P0
label 2 weeks ago
みてるぞ added the
status/ready
label 2 weeks ago
みてるぞ added the
status/in-progress
label 2 weeks ago
みてるぞ removed the
status/ready
label 2 weeks ago
みてるぞ referenced this issue from a commit 2 weeks ago
みてるぞ referenced this issue from a commit 2 weeks ago
みてるぞ removed the
status/in-progress
label 2 weeks ago
みてるぞ added the
status/review
label 2 weeks ago
みてるぞ removed the
P0
label 2 weeks ago
みてるぞ referenced this issue from a commit 2 weeks ago
みてるぞ referenced this issue from a commit 2 weeks ago
みてるぞ referenced this issue from a commit 2 weeks ago
みてるぞ referenced this issue from a commit 2 weeks ago
みてるぞ removed the
status/review
label 2 weeks ago
みてるぞ closed this issue 2 weeks ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Blocks
Loading…
There is no content yet.