The app is too slow because of the way badges are assigned.
I'm moving the code from the badge_rules.rb to an observer. In the badge_rules for every badge the app would use several database queries. Now, on answer#create the observer has a callback and first initializes all the needed variables, then it checks in seperate methods for the different conditions for different types of badges. For badges that belong to challenges there could be a ChallengesObserver. So far most badges occur on creating of an answer.
TODO
[x] Implement all badge assignment in observers
[x] Check if badge is assigned before evaluating badge_grant_condition
Fix #164
The app is too slow because of the way badges are assigned.
I'm moving the code from the badge_rules.rb to an observer. In the badge_rules for every badge the app would use several database queries. Now, on answer#create the observer has a callback and first initializes all the needed variables, then it checks in seperate methods for the different conditions for different types of badges. For badges that belong to challenges there could be a ChallengesObserver. So far most badges occur on creating of an answer.
TODO