surely now
All checks were successful
Deploy / deploy (push) Successful in 2m36s

This commit is contained in:
Lee 2024-09-28 06:37:10 +01:00
parent 0410f6b324
commit 963faa23f3
3 changed files with 12 additions and 7 deletions

@ -4,7 +4,7 @@ import { PlayerHistory } from "@/common/player/player-history";
import { config } from "../../../../../config"; import { config } from "../../../../../config";
import ky from "ky"; import ky from "ky";
import { import {
formatDate, formatDateMinimal,
getDaysAgoDate, getDaysAgoDate,
getMidnightAlignedDate, getMidnightAlignedDate,
} from "@/common/time-utils"; } from "@/common/time-utils";
@ -88,7 +88,7 @@ export async function getScoreSaberPlayerFromToken(
} }
if (history) { if (history) {
// Use the latest data for today // Use the latest data for today
history[formatDate(getMidnightAlignedDate(new Date()))] = { history[formatDateMinimal(getMidnightAlignedDate(new Date()))] = {
rank: token.rank, rank: token.rank,
countryRank: token.countryRank, countryRank: token.countryRank,
pp: token.pp, pp: token.pp,

@ -1,6 +1,6 @@
import mongoose, { Document, Schema } from "mongoose"; import mongoose, { Document, Schema } from "mongoose";
import { PlayerHistory } from "@/common/player/player-history"; import { PlayerHistory } from "@/common/player/player-history";
import { formatDate, getMidnightAlignedDate } from "@/common/time-utils"; import { formatDateMinimal, getMidnightAlignedDate } from "@/common/time-utils";
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player"; import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
// Interface for Player Document // Interface for Player Document
@ -70,7 +70,9 @@ PlayerSchema.methods.getLastTracked = function (): Date {
PlayerSchema.methods.getHistory = function (date: Date): PlayerHistory { PlayerSchema.methods.getHistory = function (date: Date): PlayerHistory {
return ( return (
this.statisticHistory.get(formatDate(getMidnightAlignedDate(date))) || {} this.statisticHistory.get(
formatDateMinimal(getMidnightAlignedDate(date)),
) || {}
); );
}; };
@ -92,7 +94,7 @@ PlayerSchema.methods.setStatisticHistory = function (
this.statisticHistory = new Map(); this.statisticHistory = new Map();
} }
return this.statisticHistory.set( return this.statisticHistory.set(
formatDate(getMidnightAlignedDate(date)), formatDateMinimal(getMidnightAlignedDate(date)),
data, data,
); );
}; };

@ -29,13 +29,16 @@ export function timeAgo(input: Date | number) {
} }
/** /**
* Formats the date * Formats the date in the format "DD MMMM YYYY"
* *
* @param date the date * @param date the date
*/ */
export function formatDate(date: Date) { export function formatDateMinimal(date: Date) {
return date.toLocaleString("en-US", { return date.toLocaleString("en-US", {
timeZone: "Europe/London", timeZone: "Europe/London",
day: "numeric",
month: "short",
year: "numeric",
}); });
} }