feat(user): Track challenge submissions count
BREAKING CHANGE: none Closes #14881
This commit is contained in:
@ -182,6 +182,7 @@
|
|||||||
{
|
{
|
||||||
"completedDate": "number",
|
"completedDate": "number",
|
||||||
"lastUpdated": "number",
|
"lastUpdated": "number",
|
||||||
|
"numOfAttempts": "number",
|
||||||
"id": "string",
|
"id": "string",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"completedWith": "string",
|
"completedWith": "string",
|
||||||
|
@ -21,13 +21,15 @@ function buildUserUpdate(
|
|||||||
const oldChallenge = challengeMap[challengeId];
|
const oldChallenge = challengeMap[challengeId];
|
||||||
const alreadyCompleted = !!oldChallenge;
|
const alreadyCompleted = !!oldChallenge;
|
||||||
|
|
||||||
|
|
||||||
if (alreadyCompleted) {
|
if (alreadyCompleted) {
|
||||||
// add data from old challenge
|
// add data from old challenge
|
||||||
finalChallenge = {
|
const attempts = oldChallenge.numOfAttempts;
|
||||||
|
const numOfAttempts = attempts ? attempts + 1 : 0;
|
||||||
|
finalChallenge = {
|
||||||
...completedChallenge,
|
...completedChallenge,
|
||||||
completedDate: oldChallenge.completedDate,
|
completedDate: oldChallenge.completedDate,
|
||||||
lastUpdated: completedChallenge.completedDate
|
lastUpdated: completedChallenge.completedDate,
|
||||||
|
numOfAttempts: numOfAttempts
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
updateData.$push = {
|
updateData.$push = {
|
||||||
@ -36,7 +38,10 @@ function buildUserUpdate(
|
|||||||
completedChallenge: challengeId
|
completedChallenge: challengeId
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
finalChallenge = completedChallenge;
|
finalChallenge = {
|
||||||
|
...completedChallenge,
|
||||||
|
numOfAttempts: 1
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
updateData.$set = {
|
updateData.$set = {
|
||||||
|
Reference in New Issue
Block a user