Prevent duplicate challenge tasks (#11502)

* Implement atomic user challenges update

Prevents multiple concurrent requests from passing through
Fixes #11295

* Move user challenges update to separate method

* Rename challenge syncToUser to syncTasksToUser

Now that adding the challenge to user is separated, this methods main purpose is to sync the tasks

* Fix lint errors
This commit is contained in:
Carl Vuorinen
2019-12-13 15:14:57 +02:00
committed by Matteo Pagliazzi
parent bdb3cf25c1
commit cd90a281c2
4 changed files with 60 additions and 17 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ async function syncChallengeToMembers (challenges) {
const promises = [];
users.forEach(user => {
promises.push(challenge.syncToUser(user));
promises.push(challenge.syncTasksToUser(user));
promises.push(challenge.save());
promises.push(user.save());
});