add comments and fix score deletion
All checks were successful
deploy / deploy (push) Successful in 29s

This commit is contained in:
Lee 2023-10-30 15:49:06 +00:00
parent 41661059a0
commit 37d86b7a7d

@ -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")