db

package
v0.0.0-...-5733806 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LogQueries = config.GenFlag[bool]("behavior.log_sql", false, "Log SQL Requests (for debugging purposes)")
)

Functions

func FormatLimitOffset

func FormatLimitOffset(limit int, offset int) string

func Get

func Get[T any](pgconn *pgxpool.Pool, ctx context.Context, dest *T, query string, args ...any) error

TODO: Remove. It's just a placeholder for old behavior

func Select

func Select[T any](pgconn *pgxpool.Pool, ctx context.Context, dest *[]*T, query string, args ...any) error

TODO: Remove. It's just a placeholder for old behavior

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewPSQL

func NewPSQL(ctx context.Context, dsn string) (*DB, error)

func (*DB) AddContestEditor

func (s *DB) AddContestEditor(ctx context.Context, contestID int, uid int) error

func (*DB) AddContestTester

func (s *DB) AddContestTester(ctx context.Context, contestID int, uid int) error

func (*DB) AddDonation

func (s *DB) AddDonation(ctx context.Context, donation *kilonova.Donation) error

func (*DB) AddProblemEditor

func (s *DB) AddProblemEditor(ctx context.Context, pbid int, uid int) error

func (*DB) AddProblemViewer

func (s *DB) AddProblemViewer(ctx context.Context, pbid int, uid int) error

func (*DB) AnswerContestQuestion

func (s *DB) AnswerContestQuestion(ctx context.Context, questionID int, response string) error

func (*DB) Attachment

func (a *DB) Attachment(ctx context.Context, filter *kilonova.AttachmentFilter) (*kilonova.Attachment, error)

func (*DB) AttachmentData

func (a *DB) AttachmentData(ctx context.Context, filter *kilonova.AttachmentFilter) ([]byte, error)

func (*DB) Attachments

func (a *DB) Attachments(ctx context.Context, filter *kilonova.AttachmentFilter) ([]*kilonova.Attachment, error)

TODO: Remove problem_attachments and blog_post_attachments views from DB

func (*DB) AuditLogCount

func (s *DB) AuditLogCount(ctx context.Context) (int, error)

func (*DB) AuditLogs

func (s *DB) AuditLogs(ctx context.Context, limit, offset int) ([]*kilonova.AuditLog, error)

func (*DB) BiggestVID

func (s *DB) BiggestVID(ctx context.Context, problemID int) (int, error)

func (*DB) BlogPost

func (s *DB) BlogPost(ctx context.Context, filter kilonova.BlogPostFilter) (*kilonova.BlogPost, error)

func (*DB) BlogPosts

func (s *DB) BlogPosts(ctx context.Context, filter kilonova.BlogPostFilter) ([]*kilonova.BlogPost, error)

func (*DB) BulkUpdateProblems

func (s *DB) BulkUpdateProblems(ctx context.Context, filter kilonova.ProblemFilter, upd kilonova.ProblemUpdate) error

func (*DB) BulkUpdateSubmissions

func (s *DB) BulkUpdateSubmissions(ctx context.Context, filter kilonova.SubmissionFilter, upd kilonova.SubmissionUpdate) error

func (*DB) ChildrenProblemListsByPblistID

func (s *DB) ChildrenProblemListsByPblistID(ctx context.Context, pblistID int) ([]*kilonova.ProblemList, error)

func (*DB) CleanupSubTasks

func (s *DB) CleanupSubTasks(ctx context.Context, pbid int) error

func (*DB) ClearUserContestSubmissions

func (s *DB) ClearUserContestSubmissions(ctx context.Context, contestID, userID int) error

func (*DB) Close

func (d *DB) Close() error

func (*DB) Contest

func (s *DB) Contest(ctx context.Context, id int) (*kilonova.Contest, error)

func (*DB) ContestAnnouncement

func (s *DB) ContestAnnouncement(ctx context.Context, id int) (*kilonova.ContestAnnouncement, error)

func (*DB) ContestAnnouncements

func (s *DB) ContestAnnouncements(ctx context.Context, contestID int) ([]*kilonova.ContestAnnouncement, error)

func (*DB) ContestClassicLeaderboard

func (s *DB) ContestClassicLeaderboard(ctx context.Context, contest *kilonova.Contest, freezeTime *time.Time) (*kilonova.ContestLeaderboard, error)

func (*DB) ContestICPCLeaderboard

func (s *DB) ContestICPCLeaderboard(ctx context.Context, contest *kilonova.Contest, freezeTime *time.Time) (*kilonova.ContestLeaderboard, error)

func (*DB) ContestMaxScore

func (s *DB) ContestMaxScore(ctx context.Context, userid, problemid, contestid int, freezeTime *time.Time) decimal.Decimal

func (*DB) ContestProblems

func (s *DB) ContestProblems(ctx context.Context, contestID int) ([]*kilonova.Problem, error)

func (*DB) ContestQuestion

func (s *DB) ContestQuestion(ctx context.Context, id int) (*kilonova.ContestQuestion, error)

func (*DB) ContestQuestions

func (s *DB) ContestQuestions(ctx context.Context, filter QuestionFilter) ([]*kilonova.ContestQuestion, error)

func (*DB) ContestRegistration

func (s *DB) ContestRegistration(ctx context.Context, contestID, userID int) (*kilonova.ContestRegistration, error)

func (*DB) ContestRegistrationCount

func (s *DB) ContestRegistrationCount(ctx context.Context, contestID int) (int, error)

func (*DB) ContestRegistrations

func (s *DB) ContestRegistrations(ctx context.Context, contestID int, fuzzyName *string, limit, offset int) ([]*kilonova.ContestRegistration, error)

func (*DB) CountBlogPosts

func (s *DB) CountBlogPosts(ctx context.Context, filter kilonova.BlogPostFilter) (int, error)

func (*DB) CountProblems

func (s *DB) CountProblems(ctx context.Context, filter kilonova.ProblemFilter) (int, error)

func (*DB) CountUsers

func (s *DB) CountUsers(ctx context.Context, filter kilonova.UserFilter) (int, error)

CountUsers retrieves the number of users matching a filter. It ignores the limit fields in `filter`.

func (*DB) CreateAuditLog

func (s *DB) CreateAuditLog(ctx context.Context, msg string, authorID *int, system bool) (int, error)

func (*DB) CreateBlogPost

func (s *DB) CreateBlogPost(ctx context.Context, title string, authorID int) (int, string, error)

func (*DB) CreateBlogPostAttachment

func (a *DB) CreateBlogPostAttachment(ctx context.Context, att *kilonova.Attachment, postID int, data []byte, authorID *int) error

func (*DB) CreateContest

func (s *DB) CreateContest(ctx context.Context, name string) (int, error)

func (*DB) CreateContestAnnouncement

func (s *DB) CreateContestAnnouncement(ctx context.Context, contestID int, text string) (int, error)

func (*DB) CreateContestQuestion

func (s *DB) CreateContestQuestion(ctx context.Context, contestID, authorID int, text string) (int, error)

func (*DB) CreatePaste

func (s *DB) CreatePaste(ctx context.Context, p *kilonova.SubmissionPaste) error

func (*DB) CreateProblem

func (s *DB) CreateProblem(ctx context.Context, p *kilonova.Problem, authorID int) error

func (*DB) CreateProblemAttachment

func (a *DB) CreateProblemAttachment(ctx context.Context, att *kilonova.Attachment, problemID int, data []byte, authorID *int) error

func (*DB) CreateProblemList

func (s *DB) CreateProblemList(ctx context.Context, list *kilonova.ProblemList) error

func (*DB) CreatePwdResetRequest

func (s *DB) CreatePwdResetRequest(ctx context.Context, id int) (string, error)

func (*DB) CreateSession

func (s *DB) CreateSession(ctx context.Context, uid int) (string, error)

func (*DB) CreateSubTask

func (s *DB) CreateSubTask(ctx context.Context, subtask *kilonova.SubTask) error

func (*DB) CreateSubmission

func (s *DB) CreateSubmission(ctx context.Context, authorID int, problem *kilonova.Problem, language eval.Language, code string, contestID *int) (int, error)

func (*DB) CreateTag

func (s *DB) CreateTag(ctx context.Context, name string, tagType kilonova.TagType) (int, error)

func (*DB) CreateTest

func (s *DB) CreateTest(ctx context.Context, test *kilonova.Test) error

func (*DB) CreateUser

func (s *DB) CreateUser(ctx context.Context, name, passwordHash, email, preferredLanguage string, theme kilonova.PreferredTheme, displayName string, generated bool) (int, error)

CreateUser creates a new user with the specified data.

func (*DB) CreateVerification

func (s *DB) CreateVerification(ctx context.Context, id int) (string, error)

func (*DB) DeleteAttachments

func (a *DB) DeleteAttachments(ctx context.Context, filter *kilonova.AttachmentFilter) (int, error)

func (*DB) DeleteBlogPost

func (s *DB) DeleteBlogPost(ctx context.Context, id int) error

func (*DB) DeleteContest

func (s *DB) DeleteContest(ctx context.Context, id int) error

func (*DB) DeleteContestAnnouncement

func (s *DB) DeleteContestAnnouncement(ctx context.Context, announcementID int) error

func (*DB) DeleteContestRegistration

func (s *DB) DeleteContestRegistration(ctx context.Context, contestID, userID int) error

func (*DB) DeleteProblem

func (s *DB) DeleteProblem(ctx context.Context, id int) error

func (*DB) DeleteProblemList

func (s *DB) DeleteProblemList(ctx context.Context, id int) error

func (*DB) DeleteProblemTests

func (s *DB) DeleteProblemTests(ctx context.Context, problemID int) ([]int, error)

func (*DB) DeleteSubPaste

func (s *DB) DeleteSubPaste(ctx context.Context, id string) error

func (*DB) DeleteSubTask

func (s *DB) DeleteSubTask(ctx context.Context, stid int) error

func (*DB) DeleteSubTasks

func (s *DB) DeleteSubTasks(ctx context.Context, pbid int) error

func (*DB) DeleteSubmission

func (s *DB) DeleteSubmission(ctx context.Context, id int) error

func (*DB) DeleteTag

func (s *DB) DeleteTag(ctx context.Context, id int) error

func (*DB) DeleteTest

func (s *DB) DeleteTest(ctx context.Context, id int) error

func (*DB) DeleteUser

func (s *DB) DeleteUser(ctx context.Context, id int) error

DeleteUser permanently deletes a user from the system.

func (*DB) Donations

func (s *DB) Donations(ctx context.Context) ([]*kilonova.Donation, error)

func (*DB) ExtendSession

func (s *DB) ExtendSession(ctx context.Context, sid string) (time.Time, error)

func (*DB) GetPwdResetRequest

func (s *DB) GetPwdResetRequest(ctx context.Context, id string) (int, error)

func (*DB) GetSession

func (s *DB) GetSession(ctx context.Context, sess string) (int, error)

func (*DB) GetVerification

func (s *DB) GetVerification(ctx context.Context, id string) (int, error)

func (*DB) InitSubmission

func (s *DB) InitSubmission(ctx context.Context, subID int) error

func (*DB) InsertContestRegistration

func (s *DB) InsertContestRegistration(ctx context.Context, contestID, userID int) error

func (*DB) IsContestViewer

func (s *DB) IsContestViewer(ctx context.Context, contestID, userID int) (bool, error)

func (*DB) IsFullProblemViewer

func (s *DB) IsFullProblemViewer(ctx context.Context, problemID, userID int) (bool, error)

func (*DB) IsPostViewer

func (s *DB) IsPostViewer(ctx context.Context, postID, userID int) (bool, error)

func (*DB) IsProblemEditor

func (s *DB) IsProblemEditor(ctx context.Context, problemID, userID int) (bool, error)

func (*DB) IsProblemViewer

func (s *DB) IsProblemViewer(ctx context.Context, problemID, userID int) (bool, error)

func (*DB) LastUsernameChange

func (s *DB) LastUsernameChange(ctx context.Context, userID int) (time.Time, error)

func (*DB) ManyProblemsTags

func (s *DB) ManyProblemsTags(ctx context.Context, problemIDs []int) (map[int][]*kilonova.Tag, error)

func (*DB) MaxScore

func (s *DB) MaxScore(ctx context.Context, userid, problemid int) decimal.Decimal

func (*DB) MaxScoreSubID

func (s *DB) MaxScoreSubID(ctx context.Context, userid, problemid int) (int, error)

func (*DB) MaximumScoreSubTaskTests

func (s *DB) MaximumScoreSubTaskTests(ctx context.Context, problemID int, userID int, contestID *int) ([]*kilonova.SubTest, error)

func (*DB) MaximumScoreSubTasks

func (s *DB) MaximumScoreSubTasks(ctx context.Context, problemID int, userID int, contestID *int) ([]*kilonova.SubmissionSubTask, error)

Note that they will probably not be from the same submission!

func (*DB) MergeTags

func (s *DB) MergeTags(ctx context.Context, original int, toReplace []int) error

original - the OG that will remain after the merge toReplace - the one that will be replaced

func (*DB) NameUsedBefore

func (s *DB) NameUsedBefore(ctx context.Context, name string) (bool, error)

func (*DB) NumBulkedSolvedPblistProblems

func (s *DB) NumBulkedSolvedPblistProblems(ctx context.Context, userID int, listIDs []int) (map[int]int, error)

func (*DB) NumSolvedPblistProblems

func (s *DB) NumSolvedPblistProblems(ctx context.Context, listID, userID int) (int, error)

func (*DB) ParentProblemListsByPblistID

func (s *DB) ParentProblemListsByPblistID(ctx context.Context, pblistID int) ([]*kilonova.ProblemList, error)

func (*DB) Problem

func (s *DB) Problem(ctx context.Context, id int) (*kilonova.Problem, error)

func (*DB) ProblemChecklist

func (s *DB) ProblemChecklist(ctx context.Context, problemID int) (*kilonova.ProblemChecklist, error)

func (*DB) ProblemEditors

func (s *DB) ProblemEditors(ctx context.Context, pbid int) ([]*User, error)

func (*DB) ProblemList

func (s *DB) ProblemList(ctx context.Context, id int) (*kilonova.ProblemList, error)

func (*DB) ProblemListByName

func (s *DB) ProblemListByName(ctx context.Context, name string) (*kilonova.ProblemList, error)

func (*DB) ProblemLists

func (s *DB) ProblemLists(ctx context.Context, filter kilonova.ProblemListFilter) ([]*kilonova.ProblemList, error)

func (*DB) ProblemListsByProblemID

func (s *DB) ProblemListsByProblemID(ctx context.Context, problemID int, showHidable bool) ([]*kilonova.ProblemList, error)

func (*DB) ProblemStatisticsMemory

func (s *DB) ProblemStatisticsMemory(ctx context.Context, problemID int) ([]*kilonova.Submission, error)

func (*DB) ProblemStatisticsSize

func (s *DB) ProblemStatisticsSize(ctx context.Context, problemID int) ([]*kilonova.Submission, error)

func (*DB) ProblemStatisticsTime

func (s *DB) ProblemStatisticsTime(ctx context.Context, problemID int) ([]*kilonova.Submission, error)

func (*DB) ProblemTags

func (s *DB) ProblemTags(ctx context.Context, problemID int) ([]*kilonova.Tag, error)

func (*DB) ProblemViewers

func (s *DB) ProblemViewers(ctx context.Context, pbid int) ([]*User, error)

func (*DB) Problems

func (s *DB) Problems(ctx context.Context, filter kilonova.ProblemFilter) ([]*kilonova.Problem, error)

func (*DB) ProblemsStatistics

func (s *DB) ProblemsStatistics(ctx context.Context, problemIDs []int) (map[int]*ProblemStats, error)

func (*DB) RefreshHotProblems

func (s *DB) RefreshHotProblems(ctx context.Context, bannedProblems []int) error

func (*DB) RefreshProblemStats

func (s *DB) RefreshProblemStats(ctx context.Context) error

func (*DB) RelevantTags

func (s *DB) RelevantTags(ctx context.Context, tagID int, max int) ([]*kilonova.Tag, error)

RelevantTags returns tags that are most commonly found in problems containing that tag

func (*DB) RemainingSubmissionCount

func (s *DB) RemainingSubmissionCount(ctx context.Context, contest *kilonova.Contest, problemID, userID int) (int, error)

func (*DB) RemovePwdResetRequest

func (s *DB) RemovePwdResetRequest(ctx context.Context, req string) error

func (*DB) RemoveSession

func (s *DB) RemoveSession(ctx context.Context, sess string) error

func (*DB) RemoveTag

func (s *DB) RemoveTag(ctx context.Context, id int) error

func (*DB) RemoveVerification

func (s *DB) RemoveVerification(ctx context.Context, verif string) error

func (*DB) ResetProblemSubmissions

func (s *DB) ResetProblemSubmissions(ctx context.Context, problemID int) error

func (*DB) ResetSubmission

func (s *DB) ResetSubmission(ctx context.Context, subID int) error

func (*DB) RunningContestsByProblem

func (s *DB) RunningContestsByProblem(ctx context.Context, problemID int) ([]*kilonova.Contest, error)

TODO: Test

func (*DB) ScoredContestProblems

func (s *DB) ScoredContestProblems(ctx context.Context, contestID int, userID int, freezeTime *time.Time) ([]*kilonova.ScoredProblem, error)

func (*DB) ScoredProblem

func (s *DB) ScoredProblem(ctx context.Context, problemID int, userID int) (*kilonova.ScoredProblem, error)

func (*DB) ScoredProblems

func (s *DB) ScoredProblems(ctx context.Context, filter kilonova.ProblemFilter, userID int) ([]*kilonova.ScoredProblem, error)

func (*DB) StartContestRegistration

func (s *DB) StartContestRegistration(ctx context.Context, contestID, userID int, startTime time.Time, endTime time.Time) error

func (*DB) StripContestAccess

func (s *DB) StripContestAccess(ctx context.Context, contestID int, uid int) error

func (*DB) StripProblemAccess

func (s *DB) StripProblemAccess(ctx context.Context, pbid int, uid int) error

func (*DB) SubTask

func (s *DB) SubTask(ctx context.Context, pbid, stvid int) (*kilonova.SubTask, error)

func (*DB) SubTaskByID

func (s *DB) SubTaskByID(ctx context.Context, stid int) (*kilonova.SubTask, error)

func (*DB) SubTasks

func (s *DB) SubTasks(ctx context.Context, pbid int) ([]*kilonova.SubTask, error)

func (*DB) SubTasksByTest

func (s *DB) SubTasksByTest(ctx context.Context, pbid, tid int) ([]*kilonova.SubTask, error)

func (*DB) SubTest

func (s *DB) SubTest(ctx context.Context, id int) (*kilonova.SubTest, error)

func (*DB) SubTestsBySubID

func (s *DB) SubTestsBySubID(ctx context.Context, subid int) ([]*kilonova.SubTest, error)

func (*DB) Submission

func (s *DB) Submission(ctx context.Context, id int) (*kilonova.Submission, error)

func (*DB) SubmissionCount

func (s *DB) SubmissionCount(ctx context.Context, filter kilonova.SubmissionFilter) (int, error)

func (*DB) SubmissionLookingUser

func (s *DB) SubmissionLookingUser(ctx context.Context, id int, userID int) (*kilonova.Submission, error)

func (*DB) SubmissionPaste

func (s *DB) SubmissionPaste(ctx context.Context, id string) (*kilonova.SubmissionPaste, error)

func (*DB) SubmissionSubTasksBySubID

func (s *DB) SubmissionSubTasksBySubID(ctx context.Context, subid int) ([]*kilonova.SubmissionSubTask, error)

func (*DB) Submissions

func (s *DB) Submissions(ctx context.Context, filter kilonova.SubmissionFilter) ([]*kilonova.Submission, error)

func (*DB) Tag

func (s *DB) Tag(ctx context.Context, id int) (*kilonova.Tag, error)

func (*DB) TagByLooseName

func (s *DB) TagByLooseName(ctx context.Context, name string) (*kilonova.Tag, error)

func (*DB) TagByName

func (s *DB) TagByName(ctx context.Context, name string) (*kilonova.Tag, error)

func (*DB) Tags

func (s *DB) Tags(ctx context.Context) ([]*kilonova.Tag, error)

func (*DB) TagsByID

func (s *DB) TagsByID(ctx context.Context, tagIDs []int) ([]*kilonova.Tag, error)

func (*DB) TagsByType

func (s *DB) TagsByType(ctx context.Context, tagType kilonova.TagType) ([]*kilonova.Tag, error)

func (*DB) Test

func (s *DB) Test(ctx context.Context, pbID, testVID int) (*kilonova.Test, error)

func (*DB) Tests

func (s *DB) Tests(ctx context.Context, pbID int) ([]*kilonova.Test, error)

func (*DB) UpdateAttachment

func (a *DB) UpdateAttachment(ctx context.Context, id int, upd *kilonova.AttachmentUpdate) error

func (*DB) UpdateAttachmentData

func (a *DB) UpdateAttachmentData(ctx context.Context, id int, data []byte, updatedBy *int) error

func (*DB) UpdateBlogPost

func (s *DB) UpdateBlogPost(ctx context.Context, id int, upd kilonova.BlogPostUpdate) error

func (*DB) UpdateContest

func (s *DB) UpdateContest(ctx context.Context, id int, upd kilonova.ContestUpdate) error

func (*DB) UpdateContestAnnouncement

func (s *DB) UpdateContestAnnouncement(ctx context.Context, announcementID int, text string) error

func (*DB) UpdateContestProblems

func (s *DB) UpdateContestProblems(ctx context.Context, contestID int, problems []int) error

func (*DB) UpdateProblem

func (s *DB) UpdateProblem(ctx context.Context, id int, upd kilonova.ProblemUpdate) error

func (*DB) UpdateProblemList

func (s *DB) UpdateProblemList(ctx context.Context, id int, upd kilonova.ProblemListUpdate) error

func (*DB) UpdateProblemListProblems

func (s *DB) UpdateProblemListProblems(ctx context.Context, id int, problemIDs []int) error

func (*DB) UpdateProblemListSublists

func (s *DB) UpdateProblemListSublists(ctx context.Context, id int, listIDs []int) error

func (*DB) UpdateProblemTags

func (s *DB) UpdateProblemTags(ctx context.Context, problemID int, tagIDs []int) error

func (*DB) UpdateSubTask

func (s *DB) UpdateSubTask(ctx context.Context, id int, upd kilonova.SubTaskUpdate) error

func (*DB) UpdateSubTaskTests

func (s *DB) UpdateSubTaskTests(ctx context.Context, id int, testIDs []int) error

func (*DB) UpdateSubTest

func (s *DB) UpdateSubTest(ctx context.Context, id int, upd kilonova.SubTestUpdate) error

func (*DB) UpdateSubmission

func (s *DB) UpdateSubmission(ctx context.Context, id int, upd kilonova.SubmissionUpdate) error

func (*DB) UpdateSubmissionSubtaskPercentage

func (s *DB) UpdateSubmissionSubtaskPercentage(ctx context.Context, id int, percentage decimal.Decimal) (err error)

func (*DB) UpdateTagName

func (s *DB) UpdateTagName(ctx context.Context, id int, newName string) error

func (*DB) UpdateTagType

func (s *DB) UpdateTagType(ctx context.Context, id int, newType kilonova.TagType) error

func (*DB) UpdateTest

func (s *DB) UpdateTest(ctx context.Context, id int, upd kilonova.TestUpdate) error

func (*DB) UpdateUser

func (s *DB) UpdateUser(ctx context.Context, id int, upd kilonova.UserFullUpdate) error

UpdateUser updates a user. Returns ENOTFOUND if the user does not exist

func (*DB) UpdateUserPasswordHash

func (s *DB) UpdateUserPasswordHash(ctx context.Context, userID int, hash string) error

func (*DB) User

func (s *DB) User(ctx context.Context, filter kilonova.UserFilter) (*User, error)

User looks up a user by ID.

func (*DB) UserExists

func (s *DB) UserExists(ctx context.Context, username string, email string) (bool, error)

UserExists says wether or not a user matches either a specific username (case-insensitive), either a specific email address.

func (*DB) UsernameChangeHistory

func (s *DB) UsernameChangeHistory(ctx context.Context, userID int) ([]*kilonova.UsernameChange, error)

func (*DB) Users

func (s *DB) Users(ctx context.Context, filter kilonova.UserFilter) ([]*User, error)

Users retrieves users based on a filter.

func (*DB) VisibleContests

func (s *DB) VisibleContests(ctx context.Context, userID int) ([]*kilonova.Contest, error)

func (*DB) VisibleFutureContests

func (s *DB) VisibleFutureContests(ctx context.Context, userID int) ([]*kilonova.Contest, error)

func (*DB) VisibleProblem

func (s *DB) VisibleProblem(ctx context.Context, id int, user *kilonova.UserBrief) (*kilonova.Problem, error)

func (*DB) VisibleRunningContests

func (s *DB) VisibleRunningContests(ctx context.Context, userID int) ([]*kilonova.Contest, error)

func (*DB) WaitingSubmissionCount

func (s *DB) WaitingSubmissionCount(ctx context.Context, userID int) (int, error)

type ProblemStats

type ProblemStats struct {
	ProblemID      int `db:"problem_id"`
	NumSolvedBy    int `db:"num_solved"`
	NumAttemptedBy int `db:"num_attempted"`
}

type ProblemTag

type ProblemTag struct {
	kilonova.Tag
	ProblemID int `db:"problem_id"`
}

type QuestionFilter

type QuestionFilter struct {
	ID        *int
	ContestID *int
	AuthorID  *int

	Limit  int
	Offset int
}

type User

type User struct {
	ID        int       `json:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	Name      string    `json:"name"`
	Admin     bool      `json:"admin"`
	Proposer  bool      `json:"proposer"`
	Email     string    `json:"email"`
	Password  string    `json:"-"`
	Bio       string    `json:"bio"`

	VerifiedEmail    bool       `json:"verified_email" db:"verified_email"`
	EmailVerifSentAt *time.Time `json:"-" db:"email_verif_sent_at"`

	PreferredLanguage string                  `json:"-" db:"preferred_language"`
	PreferredTheme    kilonova.PreferredTheme `json:"-" db:"preferred_theme"`

	NameChangeRequired bool `json:"name_change_required" db:"name_change_required"`

	LockedLogin bool `json:"locked_login" db:"locked_login"`
	Generated   bool `json:"generated" db:"generated"`

	DisplayName string `json:"display_name" db:"display_name"`
}

func (*User) ToBrief

func (user *User) ToBrief() *kilonova.UserBrief

func (*User) ToFull

func (user *User) ToFull() *kilonova.UserFull

Jump to

Keyboard shortcuts

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