DefactoSoftware / MedischRekenenArcade

Train your skills in medical arithmetics
medischrekenen.herokuapp.com
1 stars 0 forks source link

[READY] Refactor granting badges #165

Closed Marthyn closed 10 years ago

Marthyn commented 10 years ago

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

Marthyn commented 10 years ago

Tested on Heroku, increases speed significantly.

Challenges#Index from 8500ms to 333ms

Problems#index from 7500ms to 407ms