diff --git a/src/services/updateData.ts b/src/services/updateData.ts index 61cffd3..89316aa 100644 --- a/src/services/updateData.ts +++ b/src/services/updateData.ts @@ -70,7 +70,7 @@ async function connectWebsocket() { pp, } = score; const { maxScore, stars, id: leaderboardId } = leaderboard; - await Score.findByIdAndDelete(id).exec(); // Remove any existing score with the same id + await Score.deleteOne({ _id: id }); // Delete the score if it already exists const data: any = { _id: id, @@ -94,11 +94,12 @@ async function connectWebsocket() { data.stars = stars; } - Score.create(data); + Score.create(data); // Create the score const countryId = normalizedRegionName(player.country?.toLowerCase()) || "unknown"; totalCountries[countryId] = (totalCountries[countryId] || 0) + 1; totalHeadsets[hmd] = (totalHeadsets[hmd] || 0) + 1; + // Update the leaderboard data in the database await LeaderboardSchema.updateOne( { _id: "scoresaber" }, { @@ -110,6 +111,7 @@ async function connectWebsocket() { } ).exec(); + // Write the metrics data to influx InfluxWriteAPI.writePoint( new Point("scoresaber") .tag("type", "score_count")