Festinger
(Festinger )
11.Апрель.2024 07:03:31
1
Здравствуйте,
Возможно ли массово изменить владельца для 10 000+ постов на нового пользователя по категориям? Я пытался найти эту информацию на форуме, но увидел только опцию использования инструмента массового выбора, ограниченного несколькими десятками постов.
Спасибо!
Festinger
(Festinger )
11.Апрель.2024 07:28:01
2
Я нашел это здесь:
Below you will find a collection of bulk operations that can be initiated from the command line. You will need SSH access, so if you are a hosted customer, you will need to contact the Discourse team about running these commands.
Before working with the console it is extremely important that you have a recent backup. Mistakes can always happen!
First thing to do is enter your site’s container:
cd /var/discourse
./launcher enter app
Additional Guides:
Performing bulk actions a…
Получаю следующую ошибку:
[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)>
Думаю, сначала нужно выполнить первый шаг:
Taylor:
Укажите нового владельца и категории, с которыми нужно работать. Категории должны быть представлены в виде массива идентификаторов; в примере это категории 1, 2 и 3:
rails c
user = User.find_by(username_lower: "lowercase-username")
categories = [1, 2, 3]
Festinger
(Festinger )
11.Апрель.2024 13:51:23
4
Спасибо за обратную связь, @JammyDodger .
Мы указали ID категории, но забыли добавить команду rails c в начале.
Ваш вклад позволил нам выполнить команду. Спасибо!