Versions in this module Expand all Collapse all v0 v0.25.0 May 18, 2024 Changes in this version type DB + func (s *DB) CountSessions(ctx context.Context, filter *SessionFilter) (int, error) + func (s *DB) CountSignups(ctx context.Context, ip netip.Addr, since time.Time) (int, error) + func (s *DB) InsertMossSubmission(ctx context.Context, contestID int, problemID int, lang eval.Language, ...) (int, error) + func (s *DB) LastSubmissionTime(ctx context.Context, filter kilonova.SubmissionFilter) (*time.Time, error) + func (s *DB) LogSignup(ctx context.Context, userID int, ip *netip.Addr, userAgent *string) error + func (s *DB) MossSubmissions(ctx context.Context, contestID int) ([]*kilonova.MOSSSubmission, error) + func (s *DB) RunMigrations(ctx context.Context) error + func (s *DB) SessionDevices(ctx context.Context, sid string) ([]*SessionDevice, error) + func (s *DB) Sessions(ctx context.Context, filter *SessionFilter) ([]*Session, error) + func (s *DB) SubmissionCode(ctx context.Context, subID int) ([]byte, error) + func (s *DB) UpdateSessionDevice(ctx context.Context, sid string, uid int, ip *netip.Addr, userAgent *string) error + type SessionDevice struct + CreatedAt time.Time + IPAddr *netip.Addr + LastCheckedAt time.Time + SessID string + UserAgent *string + UserID *int + type SessionFilter struct + Ascending bool + ID *string + IPAddr *netip.Addr + IPPrefix *netip.Prefix + Limit int + Offset int + Ordering string + UserID *int + UserPrefix *string v0.24.0 Jan 13, 2024 Changes in this version + var LogQueries = config.GenFlag[bool]("behavior.log_sql", false, "Log SQL Requests (for debugging purposes)") + var MaxSessionCount = config.GenFlag[int]("behavior.sessions.max_concurrent", 10, ...) + func FormatLimitOffset(limit int, offset int) string + func Get[T any](pgconn *pgxpool.Pool, ctx context.Context, dest *T, query string, args ...any) error + func Select[T any](pgconn *pgxpool.Pool, ctx context.Context, dest *[]*T, query string, ...) error + type DB struct + func NewPSQL(ctx context.Context, dsn string) (*DB, error) + func (a *DB) Attachment(ctx context.Context, filter *kilonova.AttachmentFilter) (*kilonova.Attachment, error) + func (a *DB) AttachmentData(ctx context.Context, filter *kilonova.AttachmentFilter) ([]byte, error) + func (a *DB) Attachments(ctx context.Context, filter *kilonova.AttachmentFilter) ([]*kilonova.Attachment, error) + func (a *DB) CreateBlogPostAttachment(ctx context.Context, att *kilonova.Attachment, postID int, data []byte, ...) error + func (a *DB) CreateProblemAttachment(ctx context.Context, att *kilonova.Attachment, problemID int, data []byte, ...) error + func (a *DB) DeleteAttachments(ctx context.Context, filter *kilonova.AttachmentFilter) (int, error) + func (a *DB) UpdateAttachment(ctx context.Context, id int, upd *kilonova.AttachmentUpdate) error + func (a *DB) UpdateAttachmentData(ctx context.Context, id int, data []byte, updatedBy *int) error + func (d *DB) Close() error + func (s *DB) AddContestEditor(ctx context.Context, contestID int, uid int) error + func (s *DB) AddContestTester(ctx context.Context, contestID int, uid int) error + func (s *DB) AddDonation(ctx context.Context, donation *kilonova.Donation) error + func (s *DB) AddProblemEditor(ctx context.Context, pbid int, uid int) error + func (s *DB) AddProblemViewer(ctx context.Context, pbid int, uid int) error + func (s *DB) AnswerContestQuestion(ctx context.Context, questionID int, response string) error + func (s *DB) AuditLogCount(ctx context.Context) (int, error) + func (s *DB) AuditLogs(ctx context.Context, limit, offset int) ([]*kilonova.AuditLog, error) + func (s *DB) BiggestVID(ctx context.Context, problemID int) (int, error) + func (s *DB) BlogPost(ctx context.Context, filter kilonova.BlogPostFilter) (*kilonova.BlogPost, error) + func (s *DB) BlogPosts(ctx context.Context, filter kilonova.BlogPostFilter) ([]*kilonova.BlogPost, error) + func (s *DB) BulkUpdateProblems(ctx context.Context, filter kilonova.ProblemFilter, upd kilonova.ProblemUpdate) error + func (s *DB) BulkUpdateSubmissions(ctx context.Context, filter kilonova.SubmissionFilter, ...) error + func (s *DB) CancelSubscription(ctx context.Context, id int, at time.Time) error + func (s *DB) ChildrenProblemListsByPblistID(ctx context.Context, pblistID int) ([]*kilonova.ProblemList, error) + func (s *DB) CleanupSubTasks(ctx context.Context, pbid int) error + func (s *DB) ClearUserContestSubmissions(ctx context.Context, contestID, userID int) error + func (s *DB) Contest(ctx context.Context, id int) (*kilonova.Contest, error) + func (s *DB) ContestAnnouncement(ctx context.Context, id int) (*kilonova.ContestAnnouncement, error) + func (s *DB) ContestAnnouncements(ctx context.Context, contestID int) ([]*kilonova.ContestAnnouncement, error) + func (s *DB) ContestClassicLeaderboard(ctx context.Context, contest *kilonova.Contest, freezeTime *time.Time) (*kilonova.ContestLeaderboard, error) + func (s *DB) ContestCount(ctx context.Context, filter kilonova.ContestFilter) (int, error) + func (s *DB) ContestICPCLeaderboard(ctx context.Context, contest *kilonova.Contest, freezeTime *time.Time) (*kilonova.ContestLeaderboard, error) + func (s *DB) ContestInvitation(ctx context.Context, id string) (*kilonova.ContestInvitation, error) + func (s *DB) ContestInvitations(ctx context.Context, contestID int) ([]*kilonova.ContestInvitation, error) + func (s *DB) ContestMaxScore(ctx context.Context, userid, problemid, contestid int, freezeTime *time.Time) decimal.Decimal + func (s *DB) ContestProblems(ctx context.Context, contestID int) ([]*kilonova.Problem, error) + func (s *DB) ContestQuestion(ctx context.Context, id int) (*kilonova.ContestQuestion, error) + func (s *DB) ContestQuestions(ctx context.Context, filter QuestionFilter) ([]*kilonova.ContestQuestion, error) + func (s *DB) ContestRegistration(ctx context.Context, contestID, userID int) (*kilonova.ContestRegistration, error) + func (s *DB) ContestRegistrationCount(ctx context.Context, contestID int) (int, error) + func (s *DB) ContestRegistrations(ctx context.Context, contestID int, fuzzyName *string, inviteID *string, ...) ([]*kilonova.ContestRegistration, error) + func (s *DB) Contests(ctx context.Context, filter kilonova.ContestFilter) ([]*kilonova.Contest, error) + func (s *DB) CountBlogPosts(ctx context.Context, filter kilonova.BlogPostFilter) (int, error) + func (s *DB) CountProblems(ctx context.Context, filter kilonova.ProblemFilter) (int, error) + func (s *DB) CountUsers(ctx context.Context, filter kilonova.UserFilter) (int, error) + func (s *DB) CreateAuditLog(ctx context.Context, msg string, authorID *int, system bool) (int, error) + func (s *DB) CreateBlogPost(ctx context.Context, title string, authorID int) (int, string, error) + func (s *DB) CreateContest(ctx context.Context, name string, cType kilonova.ContestType) (int, error) + func (s *DB) CreateContestAnnouncement(ctx context.Context, contestID int, text string) (int, error) + func (s *DB) CreateContestInvitation(ctx context.Context, contestID int, creatorID *int) (string, error) + func (s *DB) CreateContestQuestion(ctx context.Context, contestID, authorID int, text string) (int, error) + func (s *DB) CreatePaste(ctx context.Context, p *kilonova.SubmissionPaste) error + func (s *DB) CreateProblem(ctx context.Context, p *kilonova.Problem, authorID int) error + func (s *DB) CreateProblemList(ctx context.Context, list *kilonova.ProblemList) error + func (s *DB) CreatePwdResetRequest(ctx context.Context, id int) (string, error) + func (s *DB) CreateSession(ctx context.Context, uid int) (string, error) + func (s *DB) CreateSubTask(ctx context.Context, subtask *kilonova.SubTask) error + func (s *DB) CreateSubmission(ctx context.Context, authorID int, problem *kilonova.Problem, ...) (int, error) + func (s *DB) CreateTag(ctx context.Context, name string, tagType kilonova.TagType) (int, error) + func (s *DB) CreateTest(ctx context.Context, test *kilonova.Test) error + func (s *DB) CreateUser(ctx context.Context, name, passwordHash, email, preferredLanguage string, ...) (int, error) + func (s *DB) CreateVerification(ctx context.Context, id int) (string, error) + func (s *DB) DeleteBlogPost(ctx context.Context, id int) error + func (s *DB) DeleteContest(ctx context.Context, id int) error + func (s *DB) DeleteContestAnnouncement(ctx context.Context, announcementID int) error + func (s *DB) DeleteContestRegistration(ctx context.Context, contestID, userID int) error + func (s *DB) DeleteProblem(ctx context.Context, id int) error + func (s *DB) DeleteProblemList(ctx context.Context, id int) error + func (s *DB) DeleteProblemTests(ctx context.Context, problemID int) ([]int, error) + func (s *DB) DeleteSubPaste(ctx context.Context, id string) error + func (s *DB) DeleteSubTask(ctx context.Context, stid int) error + func (s *DB) DeleteSubTasks(ctx context.Context, pbid int) error + func (s *DB) DeleteSubmission(ctx context.Context, id int) error + func (s *DB) DeleteTag(ctx context.Context, id int) error + func (s *DB) DeleteTest(ctx context.Context, id int) error + func (s *DB) DeleteUser(ctx context.Context, id int) error + func (s *DB) Donations(ctx context.Context) ([]*kilonova.Donation, error) + func (s *DB) ExtendSession(ctx context.Context, sid string) (time.Time, error) + func (s *DB) GetPwdResetRequest(ctx context.Context, id string) (int, error) + func (s *DB) GetSession(ctx context.Context, sess string) (int, error) + func (s *DB) GetVerification(ctx context.Context, id string) (int, error) + func (s *DB) InitSubmission(ctx context.Context, subID int) error + func (s *DB) InsertContestRegistration(ctx context.Context, contestID, userID int, invitationID *string) error + func (s *DB) IsContestViewer(ctx context.Context, contestID, userID int) (bool, error) + func (s *DB) IsFullProblemViewer(ctx context.Context, problemID, userID int) (bool, error) + func (s *DB) IsPostViewer(ctx context.Context, postID, userID int) (bool, error) + func (s *DB) IsProblemEditor(ctx context.Context, problemID, userID int) (bool, error) + func (s *DB) IsProblemViewer(ctx context.Context, problemID, userID int) (bool, error) + func (s *DB) LastUsernameChange(ctx context.Context, userID int) (time.Time, error) + func (s *DB) ManyProblemsTags(ctx context.Context, problemIDs []int) (map[int][]*kilonova.Tag, error) + func (s *DB) MaxScore(ctx context.Context, userid, problemid int) decimal.Decimal + func (s *DB) MaxScoreSubID(ctx context.Context, userid, problemid int) (int, error) + func (s *DB) MaximumScoreSubTaskTests(ctx context.Context, problemID int, userID int, contestID *int) ([]*kilonova.SubTest, error) + func (s *DB) MaximumScoreSubTasks(ctx context.Context, problemID int, userID int, contestID *int) ([]*kilonova.SubmissionSubTask, error) + func (s *DB) MergeTags(ctx context.Context, original int, toReplace []int) error + func (s *DB) NameUsedBefore(ctx context.Context, name string) (bool, error) + func (s *DB) NumBulkedSolvedPblistProblems(ctx context.Context, userID int, listIDs []int) (map[int]int, error) + func (s *DB) NumSolvedPblistProblems(ctx context.Context, listID, userID int) (int, error) + func (s *DB) ParentProblemListsByPblistID(ctx context.Context, pblistID int) ([]*kilonova.ProblemList, error) + func (s *DB) Problem(ctx context.Context, id int) (*kilonova.Problem, error) + func (s *DB) ProblemChecklist(ctx context.Context, problemID int) (*kilonova.ProblemChecklist, error) + func (s *DB) ProblemEditors(ctx context.Context, pbid int) ([]*User, error) + func (s *DB) ProblemList(ctx context.Context, id int) (*kilonova.ProblemList, error) + func (s *DB) ProblemListByName(ctx context.Context, name string) (*kilonova.ProblemList, error) + func (s *DB) ProblemLists(ctx context.Context, filter kilonova.ProblemListFilter) ([]*kilonova.ProblemList, error) + func (s *DB) ProblemListsByProblemID(ctx context.Context, problemID int, showHidable bool) ([]*kilonova.ProblemList, error) + func (s *DB) ProblemStatisticsMemory(ctx context.Context, problemID int) ([]*kilonova.Submission, error) + func (s *DB) ProblemStatisticsSize(ctx context.Context, problemID int) ([]*kilonova.Submission, error) + func (s *DB) ProblemStatisticsTime(ctx context.Context, problemID int) ([]*kilonova.Submission, error) + func (s *DB) ProblemTags(ctx context.Context, problemID int) ([]*kilonova.Tag, error) + func (s *DB) ProblemViewers(ctx context.Context, pbid int) ([]*User, error) + func (s *DB) Problems(ctx context.Context, filter kilonova.ProblemFilter) ([]*kilonova.Problem, error) + func (s *DB) ProblemsStatistics(ctx context.Context, problemIDs []int) (map[int]*ProblemStats, error) + func (s *DB) RefreshHotProblems(ctx context.Context, bannedProblems []int) error + func (s *DB) RefreshProblemStats(ctx context.Context) error + func (s *DB) RelevantTags(ctx context.Context, tagID int, max int) ([]*kilonova.Tag, error) + func (s *DB) RemoveOldSessions(ctx context.Context, userID int) (int, error) + func (s *DB) RemovePwdResetRequest(ctx context.Context, req string) error + func (s *DB) RemoveSession(ctx context.Context, sess string) error + func (s *DB) RemoveSessions(ctx context.Context, userID int) error + func (s *DB) RemoveTag(ctx context.Context, id int) error + func (s *DB) RemoveVerification(ctx context.Context, verif string) error + func (s *DB) ResetSubmissions(ctx context.Context, filter kilonova.SubmissionFilter) error + func (s *DB) ScoredContestProblems(ctx context.Context, contestID int, userID int, freezeTime *time.Time) ([]*kilonova.ScoredProblem, error) + func (s *DB) ScoredProblem(ctx context.Context, problemID int, userID int) (*kilonova.ScoredProblem, error) + func (s *DB) ScoredProblems(ctx context.Context, filter kilonova.ProblemFilter, userID int) ([]*kilonova.ScoredProblem, error) + func (s *DB) StartContestRegistration(ctx context.Context, contestID, userID int, startTime time.Time, ...) error + func (s *DB) StripContestAccess(ctx context.Context, contestID int, uid int) error + func (s *DB) StripProblemAccess(ctx context.Context, pbid int, uid int) error + func (s *DB) SubTask(ctx context.Context, pbid, stvid int) (*kilonova.SubTask, error) + func (s *DB) SubTaskByID(ctx context.Context, stid int) (*kilonova.SubTask, error) + func (s *DB) SubTasks(ctx context.Context, pbid int) ([]*kilonova.SubTask, error) + func (s *DB) SubTasksByTest(ctx context.Context, pbid, tid int) ([]*kilonova.SubTask, error) + func (s *DB) SubTest(ctx context.Context, id int) (*kilonova.SubTest, error) + func (s *DB) SubTestsBySubID(ctx context.Context, subid int) ([]*kilonova.SubTest, error) + func (s *DB) Submission(ctx context.Context, id int) (*kilonova.Submission, error) + func (s *DB) SubmissionCount(ctx context.Context, filter kilonova.SubmissionFilter) (int, error) + func (s *DB) SubmissionLookingUser(ctx context.Context, id int, userID int) (*kilonova.Submission, error) + func (s *DB) SubmissionPaste(ctx context.Context, id string) (*kilonova.SubmissionPaste, error) + func (s *DB) SubmissionSubTasksBySubID(ctx context.Context, subid int) ([]*kilonova.SubmissionSubTask, error) + func (s *DB) Submissions(ctx context.Context, filter kilonova.SubmissionFilter) ([]*kilonova.Submission, error) + func (s *DB) Tag(ctx context.Context, id int) (*kilonova.Tag, error) + func (s *DB) TagByLooseName(ctx context.Context, name string) (*kilonova.Tag, error) + func (s *DB) TagByName(ctx context.Context, name string) (*kilonova.Tag, error) + func (s *DB) Tags(ctx context.Context) ([]*kilonova.Tag, error) + func (s *DB) TagsByID(ctx context.Context, tagIDs []int) ([]*kilonova.Tag, error) + func (s *DB) TagsByType(ctx context.Context, tagType kilonova.TagType) ([]*kilonova.Tag, error) + func (s *DB) Test(ctx context.Context, pbID, testVID int) (*kilonova.Test, error) + func (s *DB) Tests(ctx context.Context, pbID int) ([]*kilonova.Test, error) + func (s *DB) UpdateBlogPost(ctx context.Context, id int, upd kilonova.BlogPostUpdate) error + func (s *DB) UpdateContest(ctx context.Context, id int, upd kilonova.ContestUpdate) error + func (s *DB) UpdateContestAnnouncement(ctx context.Context, announcementID int, text string) error + func (s *DB) UpdateContestInvitation(ctx context.Context, id string, expired bool) error + func (s *DB) UpdateContestProblems(ctx context.Context, contestID int, problems []int) error + func (s *DB) UpdateProblem(ctx context.Context, id int, upd kilonova.ProblemUpdate) error + func (s *DB) UpdateProblemList(ctx context.Context, id int, upd kilonova.ProblemListUpdate) error + func (s *DB) UpdateProblemListProblems(ctx context.Context, id int, problemIDs []int) error + func (s *DB) UpdateProblemListSublists(ctx context.Context, id int, listIDs []int) error + func (s *DB) UpdateProblemTags(ctx context.Context, problemID int, tagIDs []int) error + func (s *DB) UpdateSubTask(ctx context.Context, id int, upd kilonova.SubTaskUpdate) error + func (s *DB) UpdateSubTaskTests(ctx context.Context, id int, testIDs []int) error + func (s *DB) UpdateSubTest(ctx context.Context, id int, upd kilonova.SubTestUpdate) error + func (s *DB) UpdateSubmission(ctx context.Context, id int, upd kilonova.SubmissionUpdate) error + func (s *DB) UpdateSubmissionSubtaskPercentage(ctx context.Context, id int, percentage decimal.Decimal) (err error) + func (s *DB) UpdateTagName(ctx context.Context, id int, newName string) error + func (s *DB) UpdateTagType(ctx context.Context, id int, newType kilonova.TagType) error + func (s *DB) UpdateTest(ctx context.Context, id int, upd kilonova.TestUpdate) error + func (s *DB) UpdateUser(ctx context.Context, id int, upd kilonova.UserFullUpdate) error + func (s *DB) UpdateUserPasswordHash(ctx context.Context, userID int, hash string) error + func (s *DB) User(ctx context.Context, filter kilonova.UserFilter) (*User, error) + func (s *DB) UserExists(ctx context.Context, username string, email string) (bool, error) + func (s *DB) UserSessions(ctx context.Context, uid int) ([]*Session, error) + func (s *DB) UsernameChangeHistory(ctx context.Context, userID int) ([]*kilonova.UsernameChange, error) + func (s *DB) Users(ctx context.Context, filter kilonova.UserFilter) ([]*User, error) + func (s *DB) VisibleProblem(ctx context.Context, id int, user *kilonova.UserBrief) (*kilonova.Problem, error) + type ProblemStats struct + NumAttemptedBy int + NumSolvedBy int + ProblemID int + type ProblemTag struct + ProblemID int + type QuestionFilter struct + AuthorID *int + ContestID *int + ID *int + Limit int + Offset int + type Session struct + CreatedAt time.Time + ExpiresAt time.Time + ID string + UserID int + func (sess *Session) Expired() bool + type User struct + Admin bool + Bio string + CreatedAt time.Time + DisplayName string + Email string + EmailVerifSentAt *time.Time + Generated bool + ID int + LockedLogin bool + Name string + NameChangeRequired bool + Password string + PreferredLanguage string + PreferredTheme kilonova.PreferredTheme + Proposer bool + VerifiedEmail bool + func (user *User) ToBrief() *kilonova.UserBrief + func (user *User) ToFull() *kilonova.UserFull