database

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountQueuedSubmissionsBefore

func CountQueuedSubmissionsBefore(db *gorm.DB, cluster string, createdAt time.Time) (int64, error)

CountQueuedSubmissionsBefore counts the number of submissions in the queue for a specific cluster that were created before a given time.

func CreateContainer

func CreateContainer(db *gorm.DB, container *models.Container) error

Container CRUD

func CreateSubmission

func CreateSubmission(db *gorm.DB, sub *models.Submission) error

Submission CRUD

func CreateUser

func CreateUser(db *gorm.DB, user *models.User) error

User CRUD

func DeleteUser

func DeleteUser(db *gorm.DB, userID string) error

func GetAllContainers

func GetAllContainers(db *gorm.DB, filters map[string]string, limit, offset int) ([]models.Container, int64, error)

func GetAllSubmissions

func GetAllSubmissions(db *gorm.DB) ([]models.Submission, error)

func GetAllUsers

func GetAllUsers(db *gorm.DB) ([]models.User, error)

func GetBestScoresByUserID

func GetBestScoresByUserID(db *gorm.DB, userID string) ([]models.UserProblemBestScore, error)

func GetContainer

func GetContainer(db *gorm.DB, id string) (*models.Container, error)

func GetScoreHistoriesForUsers

func GetScoreHistoriesForUsers(db *gorm.DB, contestID string, userIDs []string) (map[string][]UserScoreHistoryPoint, error)

GetScoreHistoriesForUsers retrieves the score change history for a given list of users in a specific contest.

func GetSubmission

func GetSubmission(db *gorm.DB, id string) (*models.Submission, error)

func GetSubmissionCount

func GetSubmissionCount(db *gorm.DB, userID, contestID, problemID string) (int, error)

func GetSubmissionsByUserID

func GetSubmissionsByUserID(db *gorm.DB, userID string) ([]models.Submission, error)

func GetUserByGitLabID

func GetUserByGitLabID(db *gorm.DB, gitlabID string) (*models.User, error)

func GetUserByID

func GetUserByID(db *gorm.DB, id string) (*models.User, error)

func GetUserByUsername

func GetUserByUsername(db *gorm.DB, username string) (*models.User, error)

func IncrementSubmissionCount

func IncrementSubmissionCount(db *gorm.DB, userID, contestID, problemID string) error

func Init

func Init(dsn string) (*gorm.DB, error)

func IsUserRegisteredForContest

func IsUserRegisteredForContest(db *gorm.DB, userID, contestID string) (bool, error)

func RecalculateScoresForUserProblem

func RecalculateScoresForUserProblem(db *gorm.DB, userID, problemID, contestID, sourceSubmissionID string, scoreMode string, maxPerformanceScore int) error

RecalculateScoresForUserProblem recalculates scores after a submission's validity has changed. It implements distinct, comprehensive logic for both "score" and "performance" modes. sourceSubmissionID is the ID of the submission whose validity was just changed.

func RecoverInterrupted

func RecoverInterrupted(db *gorm.DB) error

func RegisterForContest

func RegisterForContest(db *gorm.DB, userID, contestID string) error

func UpdateContainer

func UpdateContainer(db *gorm.DB, container *models.Container) error

func UpdateScoresForNewSubmission

func UpdateScoresForNewSubmission(db *gorm.DB, sub *models.Submission, contestID string, newScore int) error

func UpdateScoresForPerformanceSubmission

func UpdateScoresForPerformanceSubmission(db *gorm.DB, sub *models.Submission, contestID string, maxPerformanceScore int) error

func UpdateSubmission

func UpdateSubmission(db *gorm.DB, sub *models.Submission) error

func UpdateSubmissionValidity

func UpdateSubmissionValidity(db *gorm.DB, id string, isValid bool) error

func UpdateUser

func UpdateUser(db *gorm.DB, user *models.User) error

Types

type LeaderboardEntry

type LeaderboardEntry struct {
	UserID        string         `json:"user_id"`
	Username      string         `json:"username"`
	Tags          string         `json:"tags"`
	Nickname      string         `json:"nickname"`
	AvatarURL     string         `json:"avatar_url"`
	DisableRank   bool           `json:"disable_rank"`
	TotalScore    int            `json:"total_score"`
	ProblemScores map[string]int `json:"problem_scores"`
	// contains filtered or unexported fields
}

func GetLeaderboard

func GetLeaderboard(db *gorm.DB, contestID string, selectedTags string) ([]LeaderboardEntry, error)

GetLeaderboard retrieves the leaderboard for a contest, optionally filtered by user tags. selectedTags is a comma-separated string of tags. If empty, no tag filtering is applied.

type UserScoreHistoryPoint

type UserScoreHistoryPoint struct {
	Time      time.Time `json:"time"`
	Score     int       `json:"score"`
	ProblemID string    `json:"problem_id"`
}

UserScoreHistoryPoint represents a single point in a user's score history for a contest.

func GetScoreHistoryForUser

func GetScoreHistoryForUser(db *gorm.DB, contestID string, userID string) ([]UserScoreHistoryPoint, error)

GetScoreHistoryForUser retrieves the score change history for a specific user in a specific contest.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL