[IMP] gamification: performance improvement in cron

When the cron is running on a database with a large number of goals (e.g. website_forum with thousands of users), browsing on all items is very slow.
This patch split the browse per goal.definition instead of doing one browse on every present goal.

checking the state in update method is a useless optimisation trial as in real use, goals are never draft or canceled except if manually change the state of a goal (so very low number)

Commit more often, after each rewarded user. This prevents sending twice reward emails if the cron is interrupted as too slow.