This commit is contained in:
parent
37d86b7a7d
commit
ea3a0d2753
@ -4,14 +4,8 @@ const { Schema } = mongoose;
|
|||||||
const leaderboardSchema = new Schema({
|
const leaderboardSchema = new Schema({
|
||||||
_id: String,
|
_id: String,
|
||||||
totalPlays: Number,
|
totalPlays: Number,
|
||||||
countries: {
|
countries: JSON,
|
||||||
type: Map,
|
headsets: JSON,
|
||||||
of: Number,
|
|
||||||
},
|
|
||||||
headsets: {
|
|
||||||
type: Map,
|
|
||||||
of: Number,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const LeaderboardSchema =
|
export const LeaderboardSchema =
|
||||||
|
@ -76,7 +76,6 @@ async function connectWebsocket() {
|
|||||||
_id: id,
|
_id: id,
|
||||||
player: {
|
player: {
|
||||||
id: player.id,
|
id: player.id,
|
||||||
hmd: hmd,
|
|
||||||
},
|
},
|
||||||
mistakes: {
|
mistakes: {
|
||||||
badCuts: badCuts,
|
badCuts: badCuts,
|
||||||
@ -95,10 +94,13 @@ async function connectWebsocket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Score.create(data); // Create the score
|
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;
|
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
|
// Update the leaderboard data in the database
|
||||||
await LeaderboardSchema.updateOne(
|
await LeaderboardSchema.updateOne(
|
||||||
{ _id: "scoresaber" },
|
{ _id: "scoresaber" },
|
||||||
@ -121,8 +123,8 @@ async function connectWebsocket() {
|
|||||||
InfluxWriteAPI.writePoint(
|
InfluxWriteAPI.writePoint(
|
||||||
new Point("scoresaber")
|
new Point("scoresaber")
|
||||||
.tag("type", "headsets")
|
.tag("type", "headsets")
|
||||||
.tag("hmd", Headsets.map((h) => h.name)[hmd])
|
.tag("hmd", hmdName)
|
||||||
.intField("value", totalHeadsets[hmd])
|
.intField("value", totalHeadsets[hmdName])
|
||||||
.timestamp(new Date())
|
.timestamp(new Date())
|
||||||
);
|
);
|
||||||
InfluxWriteAPI.writePoint(
|
InfluxWriteAPI.writePoint(
|
||||||
|
Loading…
Reference in New Issue
Block a user