Skip to content

Commit

Permalink
fix(groups): divide task delta by number of assigned users
Browse files Browse the repository at this point in the history
  • Loading branch information
SabreCat committed Jun 18, 2019
1 parent af0cde5 commit f2185a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion website/server/controllers/api-v3/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,10 @@ api.scoreTask = {
_id: task.group.taskId,
}).exec();

if (groupTask) await groupTask.scoreChallengeTask(delta, direction);
if (groupTask) {
const groupDelta = groupTask.group.assignedUsers ? delta / groupTask.group.assignedUsers.length : delta;
await groupTask.scoreChallengeTask(groupDelta, direction);
}
} catch (e) {
logger.error(e);
}
Expand Down
3 changes: 2 additions & 1 deletion website/server/middlewares/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ async function cronAsync (req, res) {
}).exec();

if (groupTask) {
const delta = Math.pow(0.9747, task.value) * -1;
let delta = Math.pow(0.9747, task.value) * -1;
if (groupTask.group.assignedUsers) delta /= groupTask.group.assignedUsers.length;
await groupTask.scoreChallengeTask(delta, 'down');
}
}
Expand Down

0 comments on commit f2185a9

Please sign in to comment.