Can the merit gem recalculate reputation and re-evaluate badges and ranks?

爷,独闯天下 提交于 2019-12-01 06:42:29

It is possible to recompute reputation in an app with merit gem. Merit keeps the history of which actions triggered which point/badge granting in Merit::Action model, which is mapped to merit_actions table.

Following script should work (do a back up first, as I didn't do this in production yet):

# 1. Reset all badges/points granting
Merit::BadgesSash.delete_all
Merit::Score::Point.delete_all

# 1.1 Optionally reset activity log (badges/points granted/removed until now)
Merit::ActivityLog.delete_all

# 2. Mark all `merit_actions` as unprocessed
Merit::Action.all.map{|a| a.update_attribute :processed, false }

# 3. Recompute reputation rules
Merit::Action.check_unprocessed
Merit::RankRules.new.check_rank_rules

Notes on merit internals ("General merit workflow" wiki page).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!