add comments and fix score deletion
All checks were successful
deploy / deploy (push) Successful in 29s
All checks were successful
deploy / deploy (push) Successful in 29s
This commit is contained in:
parent
41661059a0
commit
37d86b7a7d
@ -70,7 +70,7 @@ async function connectWebsocket() {
|
|||||||
pp,
|
pp,
|
||||||
} = score;
|
} = score;
|
||||||
const { maxScore, stars, id: leaderboardId } = leaderboard;
|
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 = {
|
const data: any = {
|
||||||
_id: id,
|
_id: id,
|
||||||
@ -94,11 +94,12 @@ async function connectWebsocket() {
|
|||||||
data.stars = stars;
|
data.stars = stars;
|
||||||
}
|
}
|
||||||
|
|
||||||
Score.create(data);
|
Score.create(data); // Create the score
|
||||||
const countryId =
|
const countryId =
|
||||||
normalizedRegionName(player.country?.toLowerCase()) || "unknown";
|
normalizedRegionName(player.country?.toLowerCase()) || "unknown";
|
||||||
totalCountries[countryId] = (totalCountries[countryId] || 0) + 1;
|
totalCountries[countryId] = (totalCountries[countryId] || 0) + 1;
|
||||||
totalHeadsets[hmd] = (totalHeadsets[hmd] || 0) + 1;
|
totalHeadsets[hmd] = (totalHeadsets[hmd] || 0) + 1;
|
||||||
|
// Update the leaderboard data in the database
|
||||||
await LeaderboardSchema.updateOne(
|
await LeaderboardSchema.updateOne(
|
||||||
{ _id: "scoresaber" },
|
{ _id: "scoresaber" },
|
||||||
{
|
{
|
||||||
@ -110,6 +111,7 @@ async function connectWebsocket() {
|
|||||||
}
|
}
|
||||||
).exec();
|
).exec();
|
||||||
|
|
||||||
|
// Write the metrics data to influx
|
||||||
InfluxWriteAPI.writePoint(
|
InfluxWriteAPI.writePoint(
|
||||||
new Point("scoresaber")
|
new Point("scoresaber")
|
||||||
.tag("type", "score_count")
|
.tag("type", "score_count")
|
||||||
|
Loading…
Reference in New Issue
Block a user