Skip to content

Commit

Permalink
fgh
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Oct 30, 2024
1 parent 95f973f commit eb6c70d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/storeGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const pendingUpdates = []; // Queue to store pending updates
async function processPendingUpdates() {
if (pendingUpdates.length === 0) return;

let cnt = 0;
// Group updates by user secret
const updatesByUser = {};
pendingUpdates.forEach(({ secret, xp, timeTaken, latLong }) => {
Expand Down Expand Up @@ -35,15 +36,15 @@ async function processPendingUpdates() {
});
user.totalGamesPlayed += 1;
user.totalXp += xp;
cnt++;
});
console.log(`Processed ${userUpdates.length} updates for user ${secret}`);

await user.save();
} catch (error) {
console.error(`Error saving user ${secret}:`, error.message);
}
}

console.log('Processed', cnt, 'updates');
// Clear the pending updates queue after processing
pendingUpdates.length = 0;
}
Expand Down

0 comments on commit eb6c70d

Please sign in to comment.