This commit is contained in:
parent
37d86b7a7d
commit
ea3a0d2753
@ -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 =
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user