many fixes
All checks were successful
deploy / deploy (push) Successful in 29s

This commit is contained in:
Lee 2023-10-30 16:08:47 +00:00
parent 37d86b7a7d
commit ea3a0d2753
2 changed files with 10 additions and 14 deletions

View File

@ -4,14 +4,8 @@ const { Schema } = mongoose;
const leaderboardSchema = new Schema({
_id: String,
totalPlays: Number,
countries: {
type: Map,
of: Number,
},
headsets: {
type: Map,
of: Number,
},
countries: JSON,
headsets: JSON,
});
export const LeaderboardSchema =

View File

@ -76,7 +76,6 @@ async function connectWebsocket() {
_id: id,
player: {
id: player.id,
hmd: hmd,
},
mistakes: {
badCuts: badCuts,
@ -95,10 +94,13 @@ async function connectWebsocket() {
}
Score.create(data); // Create the score
const countryId =
normalizedRegionName(player.country?.toLowerCase()) || "unknown";
const hmdName =
Headsets.find((h) => h.id.includes(hmd))?.name || "Unknown";
const countryId = normalizedRegionName(player.country) || "Unknown";
totalCountries[countryId] = (totalCountries[countryId] || 0) + 1;
totalHeadsets[hmd] = (totalHeadsets[hmd] || 0) + 1;
totalHeadsets[hmdName] = (totalHeadsets[hmdName] || 0) + 1;
// Update the leaderboard data in the database
await LeaderboardSchema.updateOne(
{ _id: "scoresaber" },
@ -121,8 +123,8 @@ async function connectWebsocket() {
InfluxWriteAPI.writePoint(
new Point("scoresaber")
.tag("type", "headsets")
.tag("hmd", Headsets.map((h) => h.name)[hmd])
.intField("value", totalHeadsets[hmd])
.tag("hmd", hmdName)
.intField("value", totalHeadsets[hmdName])
.timestamp(new Date())
);
InfluxWriteAPI.writePoint(