fix previous score
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 41s
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 41s
This commit is contained in:
parent
ad568ddf5d
commit
f156b7f582
@ -56,15 +56,10 @@ export async function initDiscordBot() {
|
||||
export async function logToChannel(channelId: DiscordChannels, message: EmbedBuilder) {
|
||||
try {
|
||||
const channel = await client.channels.fetch(channelId);
|
||||
if (channel == undefined) {
|
||||
throw new Error(`Channel "${channelId}" not found`);
|
||||
}
|
||||
if (!channel.isSendable()) {
|
||||
throw new Error(`Channel "${channelId}" is not sendable`);
|
||||
}
|
||||
|
||||
if (channel != undefined && channel.isSendable()) {
|
||||
channel.send({ embeds: [message] });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
|
@ -488,6 +488,8 @@ export class ScoreService {
|
||||
const score = getScoreSaberScoreFromToken(token.score, leaderboard, playerId);
|
||||
if (!score) return undefined;
|
||||
|
||||
console.log("boobs");
|
||||
|
||||
// Fetch additional data, previous score, and BeatSaver map concurrently
|
||||
const [additionalData, previousScore, beatSaverMap] = await Promise.all([
|
||||
this.getAdditionalScoreData(
|
||||
@ -679,7 +681,9 @@ export class ScoreService {
|
||||
leaderboardId: string,
|
||||
timestamp: Date
|
||||
): Promise<ScoreSaberPreviousScore | undefined> {
|
||||
const scores = await ScoreSaberScoreModel.find({ playerId: playerId, leaderboardId: leaderboardId });
|
||||
const scores = await ScoreSaberScoreModel.find({ playerId: playerId, leaderboardId: leaderboardId }).sort({
|
||||
timestamp: -1,
|
||||
});
|
||||
if (scores == null || scores.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
@ -689,7 +693,7 @@ export class ScoreService {
|
||||
if (scoreIndex == -1 || score == undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const previousScore = scores[scoreIndex - 1];
|
||||
const previousScore = scores[scoreIndex + 1];
|
||||
if (previousScore == undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -11,5 +11,6 @@
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"jsx": "react",
|
||||
},
|
||||
"incremental": true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user