initial index

This commit is contained in:
41666 2023-05-22 21:04:29 -04:00
parent 62cc828d6a
commit 88015a98cd
21 changed files with 343 additions and 56 deletions

View file

@ -44,6 +44,7 @@ export type Health = {
worlds: {
name: string;
status: string;
lastEvent: string;
}[];
};
@ -55,19 +56,16 @@ export type IndexResponse = {
export const indexQuery = async (): Promise<IndexResponse> => {
const query = `{
health {
ingestReachable
ingest
database
worlds {
name
status
lastEvent
}
}
allWorlds {
id
name
population {
total
nc
tr
vs
@ -77,7 +75,6 @@ export const indexQuery = async (): Promise<IndexResponse> => {
id
name
population {
total
nc
tr
vs
@ -91,8 +88,6 @@ export const indexQuery = async (): Promise<IndexResponse> => {
indexData.allWorlds.sort((a, b) => a.id - b.id);
console.log(indexData);
return indexData;
};
@ -169,3 +164,6 @@ export const worldQuery = async (worldID: string): Promise<WorldResponse> => {
return worldData;
};
export const totalPopulation = ({ nc, vs, tr }: Population): number =>
nc + vs + tr;

View file

@ -7,3 +7,24 @@ export const toTitleCase = (str: string) => {
export const pascalCaseToTitleCase = (str: string) => {
return toTitleCase(str.replace(/([A-Z])/g, " $1"));
};
export const humanTimeAgo = (ms: number) => {
const millis = Math.floor(ms % 1000);
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
if (hours > 0) {
return `${hours}h`;
}
if (minutes > 0) {
return `${minutes}m`;
}
if (seconds > 0) {
return `${seconds}s`;
}
return `${millis}ms`;
};

59
app/utils/worlds.ts Normal file
View file

@ -0,0 +1,59 @@
export const worlds: Record<
string,
{ timeZone: string; locale: string; location: string; platform: string }
> = {
"1": {
timeZone: "America/Los_Angeles",
locale: "en-US",
location: "US-W",
platform: "PC",
},
"10": {
timeZone: "UTC",
locale: "en-GB",
location: "EU",
platform: "PC",
},
"13": {
timeZone: "UTC",
locale: "en-GB",
location: "EU",
platform: "PC",
},
"17": {
timeZone: "America/New_York",
locale: "en-US",
location: "US-E",
platform: "PC",
},
"19": {
timeZone: "America/New_York",
locale: "en-US",
location: "US-E",
platform: "PC",
},
"40": {
timeZone: "Asia/Tokyo",
locale: "en-GB",
location: "JP",
platform: "PC",
},
"1000": {
timeZone: "America/New_York",
locale: "en-US",
location: "US-E",
platform: "PS4",
},
"2000": {
timeZone: "UTC",
locale: "en-GB",
location: "EU",
platform: "PS4",
},
default: {
timeZone: "UTC",
locale: "en-US",
location: "???",
platform: "???",
},
};