cleanup top scores and add timeframes to them
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { getModelForClass, index, modelOptions, plugin, Prop, ReturnModelType, Severity } from "@typegoose/typegoose";
|
||||
import { getModelForClass, modelOptions, plugin, Prop, ReturnModelType, Severity } from "@typegoose/typegoose";
|
||||
import Score from "../score";
|
||||
import { type ScoreSaberLeaderboardPlayerInfoToken } from "../../../types/token/scoresaber/score-saber-leaderboard-player-info-token";
|
||||
import { Document } from "mongoose";
|
||||
@ -20,7 +20,6 @@ import { PreviousScore } from "../previous-score";
|
||||
},
|
||||
},
|
||||
})
|
||||
@index({ leaderboardId: 1, playerId: 1, timestamp: -1 }) // Compound index for optimized queries
|
||||
@plugin(AutoIncrementID, {
|
||||
field: "_id",
|
||||
startAt: 1,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import ScoreSaberPlayer from "./impl/scoresaber-player";
|
||||
import { ChangeRange } from "./player";
|
||||
import { Timeframe } from "../timeframe";
|
||||
|
||||
export type PlayerStatValue = {
|
||||
/**
|
||||
@ -10,7 +10,7 @@ export type PlayerStatValue = {
|
||||
/**
|
||||
* The value of the stat.
|
||||
*/
|
||||
value: (player: ScoreSaberPlayer, range: ChangeRange) => number | undefined;
|
||||
value: (player: ScoreSaberPlayer, range: Timeframe) => number | undefined;
|
||||
};
|
||||
|
||||
export type PlayerStatChangeType =
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { PlayerHistory } from "./player-history";
|
||||
import { Timeframe } from "../timeframe";
|
||||
|
||||
export default class Player {
|
||||
/**
|
||||
@ -55,7 +56,6 @@ export default class Player {
|
||||
}
|
||||
}
|
||||
|
||||
export type ChangeRange = "daily" | "weekly" | "monthly";
|
||||
export type StatisticChange = {
|
||||
[key in ChangeRange]: PlayerHistory;
|
||||
[key in Timeframe]: PlayerHistory;
|
||||
};
|
||||
|
@ -1,10 +1,21 @@
|
||||
import { ScoreSaberLeaderboard } from "src/model/leaderboard/impl/scoresaber-leaderboard";
|
||||
import { ScoreSaberScore } from "../model/score/impl/scoresaber-score";
|
||||
import { PlayerScore } from "../score/player-score";
|
||||
import { Timeframe } from "../timeframe";
|
||||
|
||||
export type TopScoresResponse = {
|
||||
/**
|
||||
* The top scores.
|
||||
*/
|
||||
scores: PlayerScore<ScoreSaberScore, ScoreSaberLeaderboard>[];
|
||||
|
||||
/**
|
||||
* The timeframe returned.
|
||||
*/
|
||||
timeframe: Timeframe;
|
||||
|
||||
/**
|
||||
* The amount of scores to fetch.
|
||||
*/
|
||||
limit: number;
|
||||
};
|
||||
|
1
projects/common/src/timeframe.ts
Normal file
1
projects/common/src/timeframe.ts
Normal file
@ -0,0 +1 @@
|
||||
export type Timeframe = "daily" | "weekly" | "monthly" | "all";
|
Reference in New Issue
Block a user