fix(updated): Update completedChallenges and progressTimestamps without duplicates (#17226)
Closes #17200
This commit is contained in:
committed by
mrugesh mohapatra
parent
58a5d0d181
commit
3e52c666da
@@ -20,7 +20,7 @@ function buildUserUpdate(
|
||||
timezone
|
||||
) {
|
||||
let finalChallenge;
|
||||
const updateData = { $push: {} };
|
||||
const updateData = {};
|
||||
const { timezone: userTimezone, completedChallenges = [] } = user;
|
||||
|
||||
const oldChallenge = _.find(
|
||||
@@ -44,9 +44,11 @@ function buildUserUpdate(
|
||||
};
|
||||
}
|
||||
|
||||
updateData.$push = {
|
||||
...updateData.$push,
|
||||
completedChallenges: finalChallenge
|
||||
updateData.$set = {
|
||||
completedChallenges: _.uniqBy(
|
||||
[finalChallenge, ...completedChallenges],
|
||||
'id'
|
||||
)
|
||||
};
|
||||
|
||||
if (
|
||||
|
Reference in New Issue
Block a user