get actual heaset name and get long region name
Some checks failed
deploy / deploy (push) Failing after 31s

This commit is contained in:
Lee
2023-10-30 15:45:35 +00:00
parent 9984b416b6
commit 41661059a0
3 changed files with 42 additions and 2 deletions

View File

@ -5,6 +5,8 @@ import { InfluxWriteAPI } from "..";
import { connectMongo } from "../db/mongo";
import { LeaderboardSchema } from "../db/schemas/leaderboard";
import { Score } from "../db/schemas/score";
import { Headsets } from "../headsets";
import { normalizedRegionName } from "../utils/regionUtils";
async function update() {
const response = await axios.get("https://scoresaber.com/api/players/count");
@ -93,7 +95,8 @@ async function connectWebsocket() {
}
Score.create(data);
const countryId = player.country?.toLowerCase() || "unknown";
const countryId =
normalizedRegionName(player.country?.toLowerCase()) || "unknown";
totalCountries[countryId] = (totalCountries[countryId] || 0) + 1;
totalHeadsets[hmd] = (totalHeadsets[hmd] || 0) + 1;
await LeaderboardSchema.updateOne(
@ -116,7 +119,7 @@ async function connectWebsocket() {
InfluxWriteAPI.writePoint(
new Point("scoresaber")
.tag("type", "headsets")
.tag("hmd", hmd)
.tag("hmd", Headsets.map((h) => h.name)[hmd])
.intField("value", totalHeadsets[hmd])
.timestamp(new Date())
);