mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FEATURE: Support append when bulk tagging via rake (#9978)
New argument option for the `tags:bulk_tag_category` rake task. Backwards compatible - defaults to false (no append) if no argument given.
This commit is contained in:
parent
87673e6571
commit
76af25f753
@ -1,8 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
task "tags:bulk_tag_category", [:tags, :category] => [:environment] do |_, args|
|
||||
task "tags:bulk_tag_category", [:tags, :category, :append] => [:environment] do |_, args|
|
||||
args.with_defaults(append: false)
|
||||
tags = args[:tags].split("|")
|
||||
category_id = args[:category]
|
||||
append = args[:append]
|
||||
|
||||
if !tags || !category_id
|
||||
puts 'ERROR: Expecting tags:bulk_tag_category["tag",category_id]'
|
||||
@ -16,7 +18,7 @@ task "tags:bulk_tag_category", [:tags, :category] => [:environment] do |_, args|
|
||||
total = category.topics.count
|
||||
|
||||
category.topics.find_each do |topic|
|
||||
DiscourseTagging.tag_topic_by_names(topic, guardian, tags)
|
||||
DiscourseTagging.tag_topic_by_names(topic, guardian, tags, append: append)
|
||||
print_status(tagged += 1, total)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user