Festinger
(Festinger )
11 Aprile 2024, 7:03am
1
Ciao,
È possibile cambiare in massa la proprietà di oltre 10.000 post a un nuovo utente in base a una categoria? Ho provato a verificarlo sui forum, ma ho visto solo l’opzione per utilizzare lo strumento di selezione multipla limitato a una dozzina di post.
Grazie!
Festinger
(Festinger )
11 Aprile 2024, 7:28am
2
L’ho trovato qui:
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…
Sto ricevendo questo errore:
[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)>
Penso che tu debba fare prima la prima parte:
Taylor:
Specifica il nuovo proprietario e le categorie su cui operare. Le categorie dovrebbero essere un array di ID di categoria, le categorie 1, 2 e 3 nell’esempio:
rails c
user = User.find_by(username_lower: "lowercase-username")
categories = [1, 2, 3]
Festinger
(Festinger )
11 Aprile 2024, 1:51pm
4
Grazie per il feedback @JammyDodger .
Abbiamo specificato l’ID della categoria ma abbiamo dimenticato di inserire il comando rails c all’inizio.
Il tuo contributo ci ha permesso di eseguire il comando. Grazie!
1 Mi Piace
system
(system)
Chiuso
11 Maggio 2024, 1:52pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.