You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB
Go

package leaderboard
import "time"
// CompletionType represents how a game session ended.
type CompletionType string
const (
CompletionCompleted CompletionType = "completed"
CompletionTimedOut CompletionType = "timed_out"
CompletionAbandoned CompletionType = "abandoned"
)
// LeaderboardEntry stores one finalized game result.
type LeaderboardEntry struct {
ID string
SessionID string
PlayerID string
PlayerName string
Score int
QuestionsAsked int
QuestionsCorrect int
HintsUsed int
DurationSeconds int
SuccessRate float64
CompletionType CompletionType
CompletedAt time.Time
CreatedAt time.Time
}
// PlayerStats stores aggregated player-level ranking data.
type PlayerStats struct {
PlayerID string
PlayerName string
GamesPlayed int
GamesCompleted int
TotalScore int64
BestScore int
AvgScore float64
AvgSuccessRate float64
TotalQuestions int64
TotalCorrect int64
BestDurationSec *int
LastPlayedAt *time.Time
UpdatedAt time.Time
}
// GlobalStats stores global leaderboard aggregates.
type GlobalStats struct {
TotalGames int64
TotalPlayers int64
AvgScore float64
AvgSuccessRate float64
MaxScore int
ScoreP50 float64
ScoreP90 float64
ScoreP99 float64
UpdatedAt time.Time
}
// Window is a top/stats time filter.
type Window string
const (
WindowAll Window = "all"
Window24h Window = "24h"
Window7d Window = "7d"
Window30d Window = "30d"
)