Festinger
(Festinger )
Avril 11, 2024, 7:03
1
Salut,
Est-il possible de changer en masse la propriété de plus de 10 000 articles au profit d’un nouvel utilisateur, par catégorie ? J’ai essayé de vérifier cela sur les forums, mais je n’ai vu que l’option d’utiliser l’outil de sélection en masse limité à une douzaine d’articles.
Merci !
Festinger
(Festinger )
Avril 11, 2024, 7:28
2
Je l’ai trouvé ici :
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…
Je reçois cette erreur :
[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)>
Je pense que vous devez d’abord faire la première partie :
Taylor:
Spécifiez le nouveau propriétaire et les catégories sur lesquelles opérer. Les catégories doivent être un tableau d’identifiants de catégories, les catégories 1, 2 et 3 dans l’exemple :
rails c
user = User.find_by(username_lower: "lowercase-username")
categories = [1, 2, 3]
Festinger
(Festinger )
Avril 11, 2024, 1:51
4
Merci pour vos commentaires @JammyDodger .
Nous avons spécifié l’ID de catégorie mais avons oublié de mettre la commande rails c au début.
Votre contribution nous a permis d’exécuter la commande. Merci !
1 « J'aime »
system
(system)
A fermé ce sujet ()
Mai 11, 2024, 1:52
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.