אם אני רוצה לבנות מחדש את ספירת התגובות והסיכום, יש דרך לעשות זאת?
כמו: bundle exec rake reactions:recount
אם אני רוצה לבנות מחדש את ספירת התגובות והסיכום, יש דרך לעשות זאת?
כמו: bundle exec rake reactions:recount
האם זה יכוסה על ידי עבודת הרקע jobs::EnsureDbConsistency?
אתה יכול להפעיל אותה ידנית מדף /sidekiq/scheduler שלך אם אתה רוצה להאיץ את זה ולראות אם זה בונה מחדש את הספירות שלך.
למרות שאם תוכל להיכנס קצת יותר לפירוט לגבי למה אתה צריך לחשב אותן מחדש, זה עשוי להוסיף קצת הקשר נוסף שיכול להיות חשוב.
Thank you for your response. I was doing the test import of reactions from Xenforo to Discourse. The data was correctly imported but not showing up on posts with username and all.
Have managed to do it now.
Used this script
RAILS_ENV=production bundle exec rails runner "
counts = DiscourseReactions::ReactionUser.group(:reaction_id).count
DiscourseReactions::Reaction.where(id: counts.keys).find_each do |reaction|
reaction.update_column(:reaction_users_count, counts[reaction.id])
end
posts_to_update = Post.where(id: DiscourseReactions::Reaction.select(:post_id).distinct)
posts_to_update.find_each do |post|
post_reactions = post.reactions.where('reaction_users_count > 0')
custom_field_value = post_reactions.map do |reaction|
{
id: reaction.reaction_value,
type: reaction.reaction_type,
count: reaction.reaction_users_count
}
end
if custom_field_value.present?
post.custom_fields['discourse_reactions_reactions'] = custom_field_value.to_json
else
post.custom_fields.delete('discourse_reactions_reactions')
end
post.save_custom_fields(true)
end
"