More big updates (just incase hdd dies or something)

This commit is contained in:
zkldi
2021-07-29 19:15:24 +01:00
parent 3a80c4ac93
commit bc6d4e4d60
16 changed files with 404 additions and 40 deletions
+6
View File
@@ -45,6 +45,12 @@ export async function APIFetchV1<T = unknown>(
const rj = await res.json();
if (!rj.success) {
console.error(rj);
} else {
console.log(rj.description);
}
if (!rj.success && displayFailure) {
toast.error(rj.description, { duration: 10_000 });
}
+5
View File
@@ -0,0 +1,5 @@
export const ONE_SECOND = 1000;
export const ONE_MINUTE = ONE_SECOND * 60;
export const ONE_HOUR = ONE_MINUTE * 60;
export const ONE_DAY = ONE_HOUR * 24;
export const ONE_WEEK = ONE_DAY * 7;
+32
View File
@@ -0,0 +1,32 @@
import {
ChartDocument,
Game,
IDStrings,
integer,
SessionScoreInfo,
SongDocument,
} from "tachi-common";
export function GetPBs(scoreInfo: SessionScoreInfo[]) {
return scoreInfo.map(e => e.isNewScore === true || e.lampDelta > 0 || e.scoreDelta > 0);
}
export function CreateSongMap<G extends Game = Game>(songs: SongDocument<G>[]) {
const songMap = new Map<integer, SongDocument<G>>();
for (const song of songs) {
songMap.set(song.id, song);
}
return songMap;
}
export function CreateChartMap<I extends IDStrings = IDStrings>(charts: ChartDocument<I>[]) {
const chartMap = new Map<string, ChartDocument<I>>();
for (const chart of charts) {
chartMap.set(chart.chartID, chart);
}
return chartMap;
}