إذا كنت أرغب في إعادة بناء عدد التفاعلات والملخص، فهل هناك طريقة للقيام بذلك؟
مثل: bundle exec rake reactions:recount
إذا كنت أرغب في إعادة بناء عدد التفاعلات والملخص، فهل هناك طريقة للقيام بذلك؟
مثل: bundle exec rake reactions:recount
هل سيغطي هذا وظيفة الخلفية jobs::EnsureDbConsistency؟
يمكنك تشغيلها يدويًا من صفحة /sidekiq/scheduler إذا كنت ترغب في تسريعها ومعرفة ما إذا كانت تعيد بناء إحصائياتك.
على الرغم من أنه إذا كان بإمكانك الخوض في مزيد من التفاصيل حول سبب حاجتك إلى إعادة حسابها، فقد يضيف ذلك بعض السياق الإضافي الذي قد يكون مهمًا.
شكراً لردك. كنت أقوم باستيراد تجريبي لردود الفعل من Xenforo إلى Discourse. تم استيراد البيانات بشكل صحيح ولكنها لا تظهر في المشاركات مع اسم المستخدم وكل شيء.
لقد تمكنت من القيام بذلك الآن.
استخدمت هذا النص البرمجي
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)
"