From e048e903c331fc80e85584c8b61204914f4edf99 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 5 Feb 2025 14:36:58 +0100 Subject: [PATCH] refactor(api): delete dead code (#58577) --- api/src/routes/protected/challenge.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/api/src/routes/protected/challenge.ts b/api/src/routes/protected/challenge.ts index 85cfd1758f4..8cf2cf9b0c1 100644 --- a/api/src/routes/protected/challenge.ts +++ b/api/src/routes/protected/challenge.ts @@ -698,19 +698,16 @@ export const challengeRoutes: FastifyPluginCallbackTypebox = ( ] as CompletedChallenge; const oldResults = oldChallenge?.examResults as ExamResults; - const newChallenge = oldChallenge; - newChallenge ? (newChallenge.examResults = examResults) : null; - // only update if it's a better result if (percentCorrect > oldResults.percentCorrect) { - const updatedChallege = { + const updatedChallenge = { id, challengeType: oldChallenge.challengeType, completedDate: oldChallenge.completedDate, examResults }; - newCompletedChallenges[alreadyCompletedIndex] = updatedChallege; + newCompletedChallenges[alreadyCompletedIndex] = updatedChallenge; // TODO(Post-MVP): Try to DRY the updates. // updateUserChallengeData, for all its faults, handles the