mozilla/badgekit-api — pull request #112 by brianloveswords (2014-06-12 13:46:13+00:00)
Title: Milestone auto awarding [closes #95]

Implements milestone badge auto-awarding.

Right after a badge is issued, a call is made to `Milestones.findAndAward()` with the email address and reference to the badge that was just issued. `findAndAward` will find all eligible milestones by getting milestones associated with the most recently issued badge and filtering out the ones that A) are already awarded and B) don't yet have the minimum number of required badges earned by the user.

`findAndAward` creates badge instances in the database and returns the list of new badge instances (or in the case of no awarded milestones badges, an empty list). We then use this in the award route to create "award" webhook calls for each of those instances.