Bulk changing ownership on category base

Hi,

Is it possible to bulk change the ownership of 10.000+ posts to a new user on a category base? I tried to check this on the forums, but I only saw the option to use the bulk select tool limited to a dozen posts.

Thanks!

I found it here:

I am getting this error:

[1] pry(main)> topics = Topic.where(category_id: categories).pluck(:id)

topics.each do |topic|
  PostOwnerChanger.new(
    post_ids: Post.where(topic_id: topic).where(post_number: 1).pluck(:id),
    topic_id: topic,
[1] pry(main)> topics = Topic.where(category_id: categories).pluck(:id)
topics.each do |topic|urse.system_user,
  PostOwnerChanger.new(
    post_ids: Post.where(topic_id: topic).where(post_number: 1).pluck(:id),
    topic_id: topic,
    new_owner: user,
    acting_user: Discourse.system_user,
    skip_revision: true
  ).change_owner!
NameError: undefined local variable or method `categories' for main:Object
from (pry):1:in `__pry__'
[2] pry(main)>
[3] pry(main)>

I think you need to do the first bit first:

Thanks for the feedback @JammyDodger.

We specified the category ID but forgot to put the rails c command at the start.

Your contribution allowed us to execute the command. Thanks!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.