[FIX] gamification: challenge winner (#18901)
In the curent behaviour, the users of the challenge are ordered regardless of the goal definition (higher wins or lower wins). This impacts the report email with the podium of users and always puts higher on top. This fix changes the ordering depending on the goal definition type.
This commit is contained in:
@@ -503,8 +503,12 @@ class Challenge(models.Model):
|
||||
|
||||
line_data['own_goal_id'] = False,
|
||||
line_data['goals'] = []
|
||||
|
||||
goals = Goals.search(domain, order="completeness desc, current desc")
|
||||
if line.condition=='higher':
|
||||
goals = Goals.search(domain, order="completeness desc, current desc")
|
||||
else:
|
||||
goals = Goals.search(domain, order="completeness desc, current asc")
|
||||
import ipdb
|
||||
ipdb.set_trace()
|
||||
for ranking, goal in enumerate(goals):
|
||||
if user and goal.user_id == user:
|
||||
line_data['own_goal_id'] = goal.id
|
||||
|
||||
Reference in New Issue
Block a user