-
Notifications
You must be signed in to change notification settings - Fork 197
General merit workflow
This is an explanation of how does merit process reputation starting from an HTTP request made to an endpoint with associated rules[1]. It's meant for merit developers, not directly helpful for application set up.
-
Merit sets an application-wide
after_filter, which creates amerit_actionfor the request if that controller/action pair has associated rules. -
Controller
after_filtertellsMeritActionclass to process its unprocessed activity (will typically be the newly createdmerit_action). It can be done synchronously (default) or as a background job. -
merit_actionasks ajudgeto grant reputation, given the sash and rule in question. -
The
judgewill grant or remove badges and points from itssashaccording torule[1] conditions, logging all its activity.
[1] Reputation rules are set in the application via the DSL defined in files rules_{badge|points|rank}_methods.rb
Merit installs the following tables for the app:
-
merit_actionsis meant for internal merit usage. It is the log of "meritable" actions and who triggered them, so that it can then compute per action if points or a badge is to be granted to someone. -
sashesdefines the Sash model, which has a one-to-one relationship with your "meritable" resources. It has some internally used methods, and it avoids join models. -
badges_sashesis a relation table between Badges and "meritable" resources. There's only one join model per app, no matter how many meritable resources it has, thanks to theSashmodel. Sash indirection should be invisible for the application and should not be used. -
merit_score_pointsholds an entry for each point granting/removing, with anum_pointsinteger and an optionallogstring. They belong tomerit_scoreswhich is an indirection between meritable resources and points, which holds the different categories for which a meritable resource may be scored. - It also adds new attributes on each resource:
sash_idandlevel. -
merit_activity_logis a join model betweenmerit_actions, andbadges_sashesandmerit_score_points, which encodes which reputation was changed per action. Through database relations, one can reconstruct every change to every sash per action triggered on the app.