maybe fix player data tracking idk
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 41s

This commit is contained in:
Lee 2024-10-28 13:35:14 +00:00
parent c8fb08b192
commit df297d0c99

@ -47,8 +47,8 @@ export class PlayerService {
newPlayer.trackedSince = new Date(); newPlayer.trackedSince = new Date();
await newPlayer.save(); await newPlayer.save();
await this.seedPlayerHistory(newPlayer.id, playerToken); await this.seedPlayerHistory(newPlayer, playerToken);
await this.refreshAllPlayerScores(newPlayer.id); await this.refreshAllPlayerScores(newPlayer);
// Notify in production // Notify in production
if (isProduction()) { if (isProduction()) {
@ -83,15 +83,10 @@ export class PlayerService {
* Seeds the player's history using data from * Seeds the player's history using data from
* the ScoreSaber API. * the ScoreSaber API.
* *
* @param playerId the player id * @param player the player to seed
* @param playerToken the SoreSaber player token * @param playerToken the SoreSaber player token
*/ */
public static async seedPlayerHistory(playerId: string, playerToken: ScoreSaberPlayerToken): Promise<void> { public static async seedPlayerHistory(player: PlayerDocument, playerToken: ScoreSaberPlayerToken): Promise<void> {
const player = await PlayerModel.findById(playerId);
if (player == null) {
throw new NotFoundError(`Player "${playerId}" not found`);
}
// Loop through rankHistory in reverse, from current day backwards // Loop through rankHistory in reverse, from current day backwards
const playerRankHistory = playerToken.histories.split(",").map((value: string) => { const playerRankHistory = playerToken.histories.split(",").map((value: string) => {
return parseInt(value); return parseInt(value);
@ -255,14 +250,9 @@ export class PlayerService {
/** /**
* Refreshes all the players scores. * Refreshes all the players scores.
* *
* @param playerId the player's id * @param player the player to refresh
*/ */
public static async refreshAllPlayerScores(playerId: string) { public static async refreshAllPlayerScores(player: PlayerDocument) {
const player = await PlayerModel.findById(playerId);
if (player == null) {
throw new NotFoundError(`Player "${playerId}" not found`);
}
await this.refreshPlayerScoreSaberScores(player); await this.refreshPlayerScoreSaberScores(player);
} }