models

package
v0.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package models contains tools for working with solve objects stored in different databases like SQLite or Postgres.

Index

Constants

View Source
const (
	// LoginRole represents name of role for login action.
	LoginRole = "login"
	// LogoutRole represents name of role for logout action.
	LogoutRole = "logout"
	// RegisterRole represents name of role for register action.
	RegisterRole = "register"
	// StatusRole represents name of role for status check.
	StatusRole = "status"
	// ObserveSettingsRole represents name of role for observing settings.
	ObserveSettingsRole = "observe_settings"
	// CreateSettingRole represents name of role for creating new setting.
	CreateSettingRole = "create_setting"
	// UpdateSettingRole represents name of role for updating setting.
	UpdateSettingRole = "update_setting"
	// DeleteSettingRole represents name of role for deleting setting.
	DeleteSettingRole = "delete_setting"
	// ObserveRolesRole represents name of role for observing roles.
	ObserveRolesRole = "observe_roles"
	// CreateRoleRole represents name of role for creating new role.
	CreateRoleRole = "create_role"
	// DeleteRoleRole represents name of role for deleting role.
	DeleteRoleRole = "delete_role"
	// ObserveRoleRolesRole represents name of role for observing role roles.
	ObserveRoleRolesRole = "observe_role_roles"
	// CreateRoleRoleRole represents name of role for creating new role role.
	CreateRoleRoleRole = "create_role_role"
	// DeleteRoleRoleRole represents name of role for deleting role role.
	DeleteRoleRoleRole = "delete_role_role"
	// ObserveUserRolesRole represents name of role for observing user roles.
	ObserveUserRolesRole = "observe_user_roles"
	// CreateUserRoleRole represents name of role for attaching role to user.
	CreateUserRoleRole = "create_user_role"
	// DeleteUserRoleRole represents name of role for detaching role from user.
	DeleteUserRoleRole = "delete_user_role"
	// ObserveUserRole represents name of role for observing user.
	ObserveUserRole = "observe_user"
	// UpdateUserRole represents name of role for updating user.
	UpdateUserRole = "update_user"
	// ObserveUserEmailRole represents name of role for observing user email.
	ObserveUserEmailRole = "observe_user_email"
	// ObserveUserFirstNameRole represents name of role for observing
	// user first name.
	ObserveUserFirstNameRole = "observe_user_first_name"
	// ObserveUserLastNameRole represents name of role for observing
	// user last name.
	ObserveUserLastNameRole = "observe_user_last_name"
	// ObserveUserMiddleNameRole represents name of role for observing
	// user middle name.
	ObserveUserMiddleNameRole = "observe_user_middle_name"
	// ObserveUserSessionsRole represents name of role for observing
	// user sessions.
	ObserveUserSessionsRole = "observe_user_sessions"
	// UpdateUserPasswordRole represents name of role for updating
	// user password.
	UpdateUserPasswordRole = "update_user_password"
	// UpdateUserEmailRole represents name of role for updating user email.
	UpdateUserEmailRole = "update_user_email"
	// UpdateUserFirstNameRole represents name of role for updating
	// user first name.
	UpdateUserFirstNameRole = "update_user_first_name"
	// UpdateUserLastNameRole represents name of role for updating
	// user last name.
	UpdateUserLastNameRole = "update_user_last_name"
	// UpdateUserMiddleNameRole represents name of role for updating
	// user middle name.
	UpdateUserMiddleNameRole = "update_user_middle_name"
	// ObserveSessionRole represents role for observing session.
	ObserveSessionRole = "observe_session"
	// DeleteSessionRole represents role for deleting session.
	DeleteSessionRole = "delete_session"
	// ObserveProblemsRole represents role for observing problem list.
	ObserveProblemsRole = "observe_problems"
	// ObserveProblemRole represents role for observing problem.
	ObserveProblemRole = "observe_problem"
	// CreateProblemRole represents role for creating problem.
	CreateProblemRole = "create_problem"
	// UpdateProblemRole represents role for updating problem.
	UpdateProblemRole = "update_problem"
	// UpdateProblemOwnerRole represents role for updating problem owner.
	UpdateProblemOwnerRole = "update_problem_owner"
	// DeleteProblemRole represents role for deleting problem.
	DeleteProblemRole = "delete_problem"
	// ObserveCompilersRole represents role for observing compiler list.
	ObserveCompilersRole = "observe_compilers"
	// ObserveCompilerRole represents role for observing compiler.
	ObserveCompilerRole = "observe_compiler"
	// CreateCompilerRole represents role for creating compiler.
	CreateCompilerRole = "create_compiler"
	// UpdateCompilerRole represents role for updating compiler.
	UpdateCompilerRole = "update_compiler"
	// DeleteCompilerRole represents role for deleting compiler.
	DeleteCompilerRole = "delete_compiler"
	// ObserveSolutionsRole represents role for observing solution list.
	ObserveSolutionsRole = "observe_solutions"
	// ObserveSolutionRole represents role for observing solution.
	ObserveSolutionRole = "observe_solution"
	//
	ObserveSolutionReportTestNumber = "observe_solution_report_test_number"
	//
	ObserveSolutionReportCheckerLogs = "observe_solution_report_checker_logs"
	// ObserveContestsRole represents role for observing contest list.
	ObserveContestsRole = "observe_contests"
	// ObserveContestRole represents role for observing contest.
	ObserveContestRole = "observe_contest"
	// ObserveContestProblemsRole represents role for observing
	// contest problem list.
	ObserveContestProblemsRole = "observe_contest_problems"
	// ObserveContestProblemRole represents role for observing
	// contest problem.
	ObserveContestProblemRole = "observe_contest_problem"
	// CreateContestProblemRole represents role for creating
	// contest problem.
	CreateContestProblemRole = "create_contest_problem"
	// UpdateContestProblemRole represents role for updating
	// contest problem.
	UpdateContestProblemRole = "update_contest_problem"
	// DeleteContestProblemRole represents role for deleting
	// contest problem.
	DeleteContestProblemRole = "delete_contest_problem"
	// ObserveContestParticipantsRole represents role for observing
	// contest participant list.
	ObserveContestParticipantsRole = "observe_contest_participants"
	// ObserveContestParticipantRole represents role for observing
	// contest participant.
	ObserveContestParticipantRole = "observe_contest_participant"
	// CreateContestProblemRole represents role for creating
	// contest participant.
	CreateContestParticipantRole = "create_contest_participant"
	// DeleteContestParticipantRole represents role for deleting
	// contest participant.
	DeleteContestParticipantRole = "delete_contest_participant"
	// ObserveContestSolutionsRole represents role for observing
	// contest solution list.
	ObserveContestSolutionsRole = "observe_contest_solutions"
	// ObserveContestSolutionRole represents role for observing
	// contest solution.
	ObserveContestSolutionRole = "observe_contest_solution"
	// CreateContestSolutionRole represents role for creating
	// contest solution.
	CreateContestSolutionRole = "create_contest_solution"
	// SubmitContestSolutionRole represents role for submitting
	// contest solution.
	SubmitContestSolutionRole = "submit_contest_solution"
	// UpdateContestSolutionRole represents role for updating
	// contest solution.
	UpdateContestSolutionRole = "update_contest_solution"
	// DeleteContestSolutionRole represents role for deleting
	// contest solution.
	DeleteContestSolutionRole = "delete_contest_solution"
	// ObserveContestStandingsRole represents role for observing
	// contest standings.
	ObserveContestStandingsRole = "observe_contest_standings"
	// ObserveContestFullStandingsRole represents role for observing
	// full contest standings.
	ObserveContestFullStandingsRole = "observe_contest_full_standings"
	// ObserveContestMessagesRole represents role for observing
	// contest messages.
	ObserveContestMessagesRole = "observe_contest_messages"
	// ObserveContestMessageRole represents role for observing
	// contest message.
	ObserveContestMessageRole = "observe_contest_message"
	// CreateContestMessageRole represents role for creating
	// contest message.
	CreateContestMessageRole = "create_contest_message"
	// UpdateContestMessageRole represents role for updating
	// contest message.
	UpdateContestMessageRole = "update_contest_message"
	// DeleteContestMessageRole represents role for deleting
	// contest message.
	DeleteContestMessageRole = "delete_contest_message"
	// SubmitContestQuestionRole represents role for submitting
	// contest question.
	SubmitContestQuestionRole = "submit_contest_question"
	// CreateContestRole represents role for creating contest.
	CreateContestRole = "create_contest"
	// UpdateContestRole represents role for updating contest.
	UpdateContestRole = "update_contest"
	// UpdateContestOwnerRole represents role for updating contest owner.
	UpdateContestOwnerRole = "update_contest_owner"
	// DeleteContestRole represents role for deleting contest.
	DeleteContestRole = "delete_contest"
	// RegisterContestsRole represents role for register to contests.
	RegisterContestsRole = "register_contests"
	// RegisterContestRole represents role for register to contest.
	RegisterContestRole = "register_contest"
	// DeregisterContestRole represents role for deregister from contest.
	DeregisterContestRole = "deregister_contest"
	// ObserveFileContentRole represents role for observing file content.
	ObserveFileContentRole = "observe_file_content"
	// ObserveScopesRole represents role for observing scopes.
	ObserveScopesRole = "observe_scopes"
	// ObserveScopeRole represents role for observing scope.
	ObserveScopeRole = "observe_scope"
	// CreateScopeRole represents role for creating scope.
	CreateScopeRole = "create_scope"
	// UpdateScopeRole represents role for updating scope.
	UpdateScopeRole = "update_scope"
	// DeleteScopeRole represents role for deleting scope.
	DeleteScopeRole = "delete_scope"
	// ObserveScopeUserRole represents role for observing scope user.
	ObserveScopeUserRole = "observe_scope_user"
	// CreateScopeUserRole represents role for creating scope user.
	CreateScopeUserRole = "create_scope_user"
	// UpdateScopeUserRole represents role for updating scope user.
	UpdateScopeUserRole = "update_scope_user"
	// DeleteScopeUserRole represents role for deleting scope user.
	DeleteScopeUserRole = "delete_scope_user"
	// ConsumeTokenRole represents role for consuming token.
	ConsumeTokenRole = "consume_token_role"
)

Variables

View Source
var (
	ErrLockAcquired = fmt.Errorf("lock already acquired")
	ErrLockReleased = fmt.Errorf("lock already released")
)

Functions

func GetAccountID

func GetAccountID(ctx context.Context) int64

GetAccountID returns account ID or zero if there is no account.

func GetBuiltInRoles

func GetBuiltInRoles() []string

GetBuildInRoles returns all built-in roles.

func GetNow

func GetNow(ctx context.Context) time.Time

GetNow returns time.Now.

func WithAccountID

func WithAccountID(ctx context.Context, id int64) context.Context

WithAccountID replaces account ID.

func WithNow

func WithNow(ctx context.Context, now time.Time) context.Context

WithNow replaces time.Now.

func WithSync

func WithSync(ctx context.Context) context.Context

Types

type Account

type Account struct {

	// Kind contains kind of account.
	Kind AccountKind `db:"kind"`
	// contains filtered or unexported fields
}

Account represents an account.

func (Account) Clone

func (o Account) Clone() Account

Clone creates copy of account.

func (Account) ObjectID

func (o Account) ObjectID() int64

ObjectID returns ID of object.

func (*Account) SetObjectID

func (o *Account) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountEvent

type AccountEvent struct {
	Account
	// contains filtered or unexported fields
}

AccountEvent represents an account event.

func (AccountEvent) EventID

func (e AccountEvent) EventID() int64

EventID returns id of this event.

func (AccountEvent) EventKind

func (e AccountEvent) EventKind() EventKind

EventKind returns type of this event.

func (AccountEvent) EventTime

func (e AccountEvent) EventTime() time.Time

EventTime returns time of this event.

func (AccountEvent) Object

func (e AccountEvent) Object() Account

Object returns event account.

func (AccountEvent) ObjectID

func (o AccountEvent) ObjectID() int64

ObjectID returns ID of object.

func (*AccountEvent) SetEventAccountID

func (e *AccountEvent) SetEventAccountID(accountID int64)

func (*AccountEvent) SetEventID

func (e *AccountEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*AccountEvent) SetEventKind

func (e *AccountEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*AccountEvent) SetEventTime

func (e *AccountEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*AccountEvent) SetObject

func (e *AccountEvent) SetObject(o Account)

SetObject sets event account.

func (*AccountEvent) SetObjectID

func (o *AccountEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountKind

type AccountKind int

AccountKind represents kind of account.

const (
	// UserAccount represents kind of account for user.
	UserAccount AccountKind = 1
	// ScopeUserAccount represents kind of account for scope user.
	ScopeUserAccount AccountKind = 2
	// ScopeAccount represents kind of account for scope.
	ScopeAccount AccountKind = 3
)

type AccountRole

type AccountRole struct {

	// AccountID contains account ID.
	AccountID int64 `db:"account_id"`
	// RoleID contains role ID.
	RoleID int64 `db:"role_id"`
	// contains filtered or unexported fields
}

AccountRole represents a account role.

func (AccountRole) Clone

func (o AccountRole) Clone() AccountRole

Clone creates copy of account role.

func (AccountRole) ObjectID

func (o AccountRole) ObjectID() int64

ObjectID returns ID of object.

func (*AccountRole) SetObjectID

func (o *AccountRole) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountRoleEvent

type AccountRoleEvent struct {
	AccountRole
	// contains filtered or unexported fields
}

AccountRoleEvent represents account role event.

func (AccountRoleEvent) EventID

func (e AccountRoleEvent) EventID() int64

EventID returns id of this event.

func (AccountRoleEvent) EventKind

func (e AccountRoleEvent) EventKind() EventKind

EventKind returns type of this event.

func (AccountRoleEvent) EventTime

func (e AccountRoleEvent) EventTime() time.Time

EventTime returns time of this event.

func (AccountRoleEvent) Object

func (e AccountRoleEvent) Object() AccountRole

Object returns account role.

func (AccountRoleEvent) ObjectID

func (o AccountRoleEvent) ObjectID() int64

ObjectID returns ID of object.

func (*AccountRoleEvent) SetEventAccountID

func (e *AccountRoleEvent) SetEventAccountID(accountID int64)

func (*AccountRoleEvent) SetEventID

func (e *AccountRoleEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*AccountRoleEvent) SetEventKind

func (e *AccountRoleEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*AccountRoleEvent) SetEventTime

func (e *AccountRoleEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*AccountRoleEvent) SetObject

func (e *AccountRoleEvent) SetObject(o AccountRole)

SetObject sets event account role.

func (*AccountRoleEvent) SetObjectID

func (o *AccountRoleEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountRoleStore

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

AccountRoleStore represents store for account roles.

func NewAccountRoleStore

func NewAccountRoleStore(
	db *gosql.DB, table, eventTable string,
) *AccountRoleStore

NewAccountRoleStore creates a new instance of AccountRoleStore.

func (*AccountRoleStore) All

func (s *AccountRoleStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*AccountRoleStore) Create

func (s *AccountRoleStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*AccountRoleStore) DB

func (s *AccountRoleStore) DB() *gosql.DB

DB returns store database.

func (*AccountRoleStore) Delete

func (s *AccountRoleStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*AccountRoleStore) Events

func (s *AccountRoleStore) Events() db.EventROStore[E]

func (*AccountRoleStore) Find

func (s *AccountRoleStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*AccountRoleStore) FindByAccount

func (s *AccountRoleStore) FindByAccount(id int64) ([]AccountRole, error)

FindByAccount returns roles by account ID.

func (*AccountRoleStore) FindOne

func (s *AccountRoleStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*AccountRoleStore) Get

func (s *AccountRoleStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*AccountRoleStore) Init

func (s *AccountRoleStore) Init(ctx context.Context) error

func (*AccountRoleStore) Objects

func (s *AccountRoleStore) Objects() db.ObjectROStore[T]

func (*AccountRoleStore) ReverseAll

func (s *AccountRoleStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*AccountRoleStore) Sync

func (s *AccountRoleStore) Sync(ctx context.Context) error

func (*AccountRoleStore) TrySync

func (s *AccountRoleStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*AccountRoleStore) Update

func (s *AccountRoleStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type AccountStore

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

AccountStore represents store for accounts.

func NewAccountStore

func NewAccountStore(
	db *gosql.DB, table, eventTable string,
) *AccountStore

NewAccountStore creates a new instance of AccountStore.

func (*AccountStore) All

func (s *AccountStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*AccountStore) Create

func (s *AccountStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*AccountStore) DB

func (s *AccountStore) DB() *gosql.DB

DB returns store database.

func (*AccountStore) Delete

func (s *AccountStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*AccountStore) Events

func (s *AccountStore) Events() db.EventROStore[E]

func (*AccountStore) Find

func (s *AccountStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*AccountStore) FindOne

func (s *AccountStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*AccountStore) Get

func (s *AccountStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*AccountStore) Init

func (s *AccountStore) Init(ctx context.Context) error

func (*AccountStore) Objects

func (s *AccountStore) Objects() db.ObjectROStore[T]

func (*AccountStore) ReverseAll

func (s *AccountStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*AccountStore) Sync

func (s *AccountStore) Sync(ctx context.Context) error

func (*AccountStore) TrySync

func (s *AccountStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*AccountStore) Update

func (s *AccountStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type CachedStore

type CachedStore interface {
	Init(ctx context.Context) error
	Sync(ctx context.Context) error
}

CachedStore represents cached store.

type Cloner

type Cloner[T any] interface {
	Clone() T
}

Cloner represents object that can be cloned.

type Compiler

type Compiler struct {
	OwnerID NInt64 `db:"owner_id"`
	Name    string `db:"name"`
	Config  JSON   `db:"config"`
	ImageID int64  `db:"image_id"`
	// contains filtered or unexported fields
}

Compiler represents compiler.

func (Compiler) Clone

func (o Compiler) Clone() Compiler

Clone create copy of compiler.

func (Compiler) GetConfig

func (o Compiler) GetConfig() (CompilerConfig, error)

func (Compiler) ObjectID

func (o Compiler) ObjectID() int64

ObjectID returns ID of object.

func (*Compiler) SetConfig

func (o *Compiler) SetConfig(config CompilerConfig) error

func (*Compiler) SetObjectID

func (o *Compiler) SetObjectID(id int64)

SetObjectID updates ID of object.

type CompilerCommandConfig

type CompilerCommandConfig struct {
	Command string   `json:"command"`
	Environ []string `json:"environ"`
	Workdir string   `json:"workdir"`
	Source  *string  `json:"source,omitempty"`
	Binary  *string  `json:"binary,omitempty"`
}

type CompilerConfig

type CompilerConfig struct {
	Language   string                 `json:"language,omitempty"`
	Compiler   string                 `json:"compiler,omitempty"`
	Extensions []string               `json:"extensions"`
	Compile    *CompilerCommandConfig `json:"compile,omitempty"`
	Execute    *CompilerCommandConfig `json:"execute,omitempty"`
}

type CompilerEvent

type CompilerEvent struct {
	Compiler
	// contains filtered or unexported fields
}

CompilerEvent represents compiler event.

func (CompilerEvent) EventID

func (e CompilerEvent) EventID() int64

EventID returns id of this event.

func (CompilerEvent) EventKind

func (e CompilerEvent) EventKind() EventKind

EventKind returns type of this event.

func (CompilerEvent) EventTime

func (e CompilerEvent) EventTime() time.Time

EventTime returns time of this event.

func (CompilerEvent) Object

func (e CompilerEvent) Object() Compiler

Object returns event compiler.

func (CompilerEvent) ObjectID

func (o CompilerEvent) ObjectID() int64

ObjectID returns ID of object.

func (*CompilerEvent) SetEventAccountID

func (e *CompilerEvent) SetEventAccountID(accountID int64)

func (*CompilerEvent) SetEventID

func (e *CompilerEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*CompilerEvent) SetEventKind

func (e *CompilerEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*CompilerEvent) SetEventTime

func (e *CompilerEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*CompilerEvent) SetObject

func (e *CompilerEvent) SetObject(o Compiler)

SetObject sets event compiler.

func (*CompilerEvent) SetObjectID

func (o *CompilerEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type CompilerStore

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

CompilerStore represents store for compilers.

func NewCompilerStore

func NewCompilerStore(db *gosql.DB, table, eventTable string) *CompilerStore

NewCompilerStore creates a new instance of CompilerStore.

func (*CompilerStore) All

func (s *CompilerStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*CompilerStore) Create

func (s *CompilerStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*CompilerStore) DB

func (s *CompilerStore) DB() *gosql.DB

DB returns store database.

func (*CompilerStore) Delete

func (s *CompilerStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*CompilerStore) Events

func (s *CompilerStore) Events() db.EventROStore[E]

func (*CompilerStore) Find

func (s *CompilerStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*CompilerStore) FindOne

func (s *CompilerStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*CompilerStore) Get

func (s *CompilerStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*CompilerStore) GetByName

func (s *CompilerStore) GetByName(name string) (Compiler, error)

GetByName returns compiler by name.

func (*CompilerStore) Init

func (s *CompilerStore) Init(ctx context.Context) error

func (*CompilerStore) Objects

func (s *CompilerStore) Objects() db.ObjectROStore[T]

func (*CompilerStore) ReverseAll

func (s *CompilerStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*CompilerStore) Sync

func (s *CompilerStore) Sync(ctx context.Context) error

func (*CompilerStore) TrySync

func (s *CompilerStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*CompilerStore) Update

func (s *CompilerStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type ConfirmEmailTokenConfig

type ConfirmEmailTokenConfig struct {
	Email string `json:"string"`
}

func (ConfirmEmailTokenConfig) TokenKind

func (c ConfirmEmailTokenConfig) TokenKind() TokenKind

type Contest

type Contest struct {
	OwnerID NInt64 `db:"owner_id"`
	Config  JSON   `db:"config"`
	Title   string `db:"title"`
	// contains filtered or unexported fields
}

Contest represents a contest.

func (Contest) Clone

func (o Contest) Clone() Contest

Clone creates copy of contest.

func (Contest) GetConfig

func (o Contest) GetConfig() (ContestConfig, error)

func (Contest) ObjectID

func (o Contest) ObjectID() int64

ObjectID returns ID of object.

func (*Contest) SetConfig

func (o *Contest) SetConfig(config ContestConfig) error

func (*Contest) SetObjectID

func (o *Contest) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestConfig

type ContestConfig struct {
	BeginTime           NInt64        `json:"begin_time,omitempty"`
	Duration            int           `json:"duration,omitempty"`
	EnableRegistration  bool          `json:"enable_registration"`
	EnableUpsolving     bool          `json:"enable_upsolving"`
	EnableObserving     bool          `json:"enable_observing,omitempty"`
	FreezeBeginDuration int           `json:"freeze_begin_duration,omitempty"`
	FreezeEndTime       NInt64        `json:"freeze_end_time,omitempty"`
	StandingsKind       StandingsKind `json:"standings_kind,omitempty"`
}

type ContestEvent

type ContestEvent struct {
	Contest
	// contains filtered or unexported fields
}

ContestEvent represents a contest event.

func (ContestEvent) EventID

func (e ContestEvent) EventID() int64

EventID returns id of this event.

func (ContestEvent) EventKind

func (e ContestEvent) EventKind() EventKind

EventKind returns type of this event.

func (ContestEvent) EventTime

func (e ContestEvent) EventTime() time.Time

EventTime returns time of this event.

func (ContestEvent) Object

func (e ContestEvent) Object() Contest

Object returns event contest.

func (ContestEvent) ObjectID

func (o ContestEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ContestEvent) SetEventAccountID

func (e *ContestEvent) SetEventAccountID(accountID int64)

func (*ContestEvent) SetEventID

func (e *ContestEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ContestEvent) SetEventKind

func (e *ContestEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ContestEvent) SetEventTime

func (e *ContestEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ContestEvent) SetObject

func (e *ContestEvent) SetObject(o Contest)

SetObject sets event contest.

func (*ContestEvent) SetObjectID

func (o *ContestEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestMessage

type ContestMessage struct {
	ContestID     int64              `db:"contest_id"`
	ParticipantID NInt64             `db:"participant_id"`
	AuthorID      int64              `db:"author_id"`
	Kind          ContestMessageKind `db:"kind"`
	ParentID      NInt64             `db:"parent_id"`
	Title         string             `db:"title"`
	Description   string             `db:"description"`
	CreateTime    int64              `db:"create_time"`
	ProblemID     NInt64             `db:"problem_id"`
	// contains filtered or unexported fields
}

func (ContestMessage) Clone

func (o ContestMessage) Clone() ContestMessage

Clone create copy of contest message.

func (ContestMessage) ObjectID

func (o ContestMessage) ObjectID() int64

ObjectID returns ID of object.

func (*ContestMessage) SetObjectID

func (o *ContestMessage) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestMessageEvent

type ContestMessageEvent struct {
	ContestMessage
	// contains filtered or unexported fields
}

func (ContestMessageEvent) EventID

func (e ContestMessageEvent) EventID() int64

EventID returns id of this event.

func (ContestMessageEvent) EventKind

func (e ContestMessageEvent) EventKind() EventKind

EventKind returns type of this event.

func (ContestMessageEvent) EventTime

func (e ContestMessageEvent) EventTime() time.Time

EventTime returns time of this event.

func (ContestMessageEvent) Object

Object returns event contest message.

func (ContestMessageEvent) ObjectID

func (o ContestMessageEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ContestMessageEvent) SetEventAccountID

func (e *ContestMessageEvent) SetEventAccountID(accountID int64)

func (*ContestMessageEvent) SetEventID

func (e *ContestMessageEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ContestMessageEvent) SetEventKind

func (e *ContestMessageEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ContestMessageEvent) SetEventTime

func (e *ContestMessageEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ContestMessageEvent) SetObject

func (e *ContestMessageEvent) SetObject(o ContestMessage)

SetObject sets event contest message.

func (*ContestMessageEvent) SetObjectID

func (o *ContestMessageEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestMessageKind

type ContestMessageKind int
const (
	RegularContestMessage  ContestMessageKind = 0
	QuestionContestMessage ContestMessageKind = 1
	AnswerContestMessage   ContestMessageKind = 2
)

func (ContestMessageKind) String

func (k ContestMessageKind) String() string

type ContestMessageStore

type ContestMessageStore interface {
	Store[ContestMessage, ContestMessageEvent]
	FindByContest(ctx context.Context, contestID int64) (db.Rows[ContestMessage], error)
}

func NewCachedContestMessageStore

func NewCachedContestMessageStore(
	db *gosql.DB, table, eventTable string,
) ContestMessageStore

type ContestParticipant

type ContestParticipant struct {

	// ContestID contains ID of contest.
	ContestID int64 `db:"contest_id"`
	// AccountID contains ID of account.
	AccountID int64 `db:"account_id"`
	// Kind contains participant kind.
	Kind ParticipantKind `db:"kind"`
	// Config contains participant config.
	Config JSON `db:"config"`
	// contains filtered or unexported fields
}

ContestParticipant represents participant.

func (ContestParticipant) Clone

Clone creates copy of contest participant.

func (ContestParticipant) ObjectID

func (o ContestParticipant) ObjectID() int64

ObjectID returns ID of object.

func (ContestParticipant) ScanConfig

func (o ContestParticipant) ScanConfig(config any) error

func (*ContestParticipant) SetConfig

func (o *ContestParticipant) SetConfig(config any) error

func (*ContestParticipant) SetObjectID

func (o *ContestParticipant) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestParticipantEvent

type ContestParticipantEvent struct {
	ContestParticipant
	// contains filtered or unexported fields
}

ContestParticipant represents participant event.

func (ContestParticipantEvent) EventID

func (e ContestParticipantEvent) EventID() int64

EventID returns id of this event.

func (ContestParticipantEvent) EventKind

func (e ContestParticipantEvent) EventKind() EventKind

EventKind returns type of this event.

func (ContestParticipantEvent) EventTime

func (e ContestParticipantEvent) EventTime() time.Time

EventTime returns time of this event.

func (ContestParticipantEvent) Object

Object returns event participant.

func (ContestParticipantEvent) ObjectID

func (o ContestParticipantEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ContestParticipantEvent) SetEventAccountID

func (e *ContestParticipantEvent) SetEventAccountID(accountID int64)

func (*ContestParticipantEvent) SetEventID

func (e *ContestParticipantEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ContestParticipantEvent) SetEventKind

func (e *ContestParticipantEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ContestParticipantEvent) SetEventTime

func (e *ContestParticipantEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ContestParticipantEvent) SetObject

SetObject sets event contest participant.

func (*ContestParticipantEvent) SetObjectID

func (o *ContestParticipantEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestParticipantStore

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

ContestParticipantStore represents a participant store.

func NewContestParticipantStore

func NewContestParticipantStore(
	db *gosql.DB, table, eventTable string,
) *ContestParticipantStore

NewContestParticipantStore creates a new instance of ContestParticipantStore.

func (*ContestParticipantStore) All

func (s *ContestParticipantStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ContestParticipantStore) Create

func (s *ContestParticipantStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ContestParticipantStore) DB

func (s *ContestParticipantStore) DB() *gosql.DB

DB returns store database.

func (*ContestParticipantStore) Delete

func (s *ContestParticipantStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ContestParticipantStore) Events

func (s *ContestParticipantStore) Events() db.EventROStore[E]

func (*ContestParticipantStore) Find

func (s *ContestParticipantStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ContestParticipantStore) FindByContest

func (s *ContestParticipantStore) FindByContest(
	id int64,
) ([]ContestParticipant, error)

func (*ContestParticipantStore) FindByContestAccount

func (s *ContestParticipantStore) FindByContestAccount(
	contestID int64, accountID int64,
) ([]ContestParticipant, error)

FindByContestAccount returns participants by contest and account.

func (*ContestParticipantStore) FindOne

func (s *ContestParticipantStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ContestParticipantStore) Get

func (s *ContestParticipantStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ContestParticipantStore) Init

func (s *ContestParticipantStore) Init(ctx context.Context) error

func (*ContestParticipantStore) Objects

func (s *ContestParticipantStore) Objects() db.ObjectROStore[T]

func (*ContestParticipantStore) ReverseAll

func (s *ContestParticipantStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ContestParticipantStore) Sync

func (s *ContestParticipantStore) Sync(ctx context.Context) error

func (*ContestParticipantStore) TrySync

func (s *ContestParticipantStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ContestParticipantStore) Update

func (s *ContestParticipantStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type ContestProblem

type ContestProblem struct {

	// ProblemID contains ID of problem.
	ProblemID int64 `db:"problem_id"`
	// ContestID contains ID of contest.
	ContestID int64 `db:"contest_id"`
	// Code contains code of problem.
	Code string `db:"code"`
	// Config contains problem config.
	Config JSON `db:"config"`
	// contains filtered or unexported fields
}

ContestProblem represents connection for problems.

func (ContestProblem) Clone

func (o ContestProblem) Clone() ContestProblem

Clone creates copy of contest problem.

func (ContestProblem) GetConfig

func (o ContestProblem) GetConfig() (ContestProblemConfig, error)

func (ContestProblem) ObjectID

func (o ContestProblem) ObjectID() int64

ObjectID returns ID of object.

func (*ContestProblem) SetConfig

func (o *ContestProblem) SetConfig(config ContestProblemConfig) error

func (*ContestProblem) SetObjectID

func (o *ContestProblem) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestProblemConfig

type ContestProblemConfig struct {
	Points *int `json:"points,omitempty"`
	// Locales contains list of allowed locales.
	Locales []string `json:"locales,omitempty"`
}

type ContestProblemEvent

type ContestProblemEvent struct {
	ContestProblem
	// contains filtered or unexported fields
}

ContestProblemEvent represents problem event.

func (ContestProblemEvent) EventID

func (e ContestProblemEvent) EventID() int64

EventID returns id of this event.

func (ContestProblemEvent) EventKind

func (e ContestProblemEvent) EventKind() EventKind

EventKind returns type of this event.

func (ContestProblemEvent) EventTime

func (e ContestProblemEvent) EventTime() time.Time

EventTime returns time of this event.

func (ContestProblemEvent) Object

Object returns event role edge.

func (ContestProblemEvent) ObjectID

func (o ContestProblemEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ContestProblemEvent) SetEventAccountID

func (e *ContestProblemEvent) SetEventAccountID(accountID int64)

func (*ContestProblemEvent) SetEventID

func (e *ContestProblemEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ContestProblemEvent) SetEventKind

func (e *ContestProblemEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ContestProblemEvent) SetEventTime

func (e *ContestProblemEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ContestProblemEvent) SetObject

func (e *ContestProblemEvent) SetObject(o ContestProblem)

SetObject sets event contest problem.

func (*ContestProblemEvent) SetObjectID

func (o *ContestProblemEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestProblemStore

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

ContestProblemStore represents a problem store.

func NewContestProblemStore

func NewContestProblemStore(
	db *gosql.DB, table, eventTable string,
) *ContestProblemStore

NewContestProblemStore creates a new instance of ContestProblemStore.

func (*ContestProblemStore) All

func (s *ContestProblemStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ContestProblemStore) Create

func (s *ContestProblemStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ContestProblemStore) DB

func (s *ContestProblemStore) DB() *gosql.DB

DB returns store database.

func (*ContestProblemStore) Delete

func (s *ContestProblemStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ContestProblemStore) Events

func (s *ContestProblemStore) Events() db.EventROStore[E]

func (*ContestProblemStore) Find

func (s *ContestProblemStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ContestProblemStore) FindByContest

func (s *ContestProblemStore) FindByContest(id int64) ([]ContestProblem, error)

FindByContest returns problems by parent ID.

func (*ContestProblemStore) FindOne

func (s *ContestProblemStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ContestProblemStore) Get

func (s *ContestProblemStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ContestProblemStore) Init

func (s *ContestProblemStore) Init(ctx context.Context) error

func (*ContestProblemStore) Objects

func (s *ContestProblemStore) Objects() db.ObjectROStore[T]

func (*ContestProblemStore) ReverseAll

func (s *ContestProblemStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ContestProblemStore) Sync

func (s *ContestProblemStore) Sync(ctx context.Context) error

func (*ContestProblemStore) TrySync

func (s *ContestProblemStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ContestProblemStore) Update

func (s *ContestProblemStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type ContestSolution

type ContestSolution struct {

	// SolutionID contains ID of solution.
	SolutionID int64 `db:"solution_id"`
	// ContestID contains ID of contest.
	ContestID int64 `db:"contest_id"`
	// ParticipantID contains ID of participant.
	ParticipantID int64 `db:"participant_id"`
	// ProblemID contains ID of contest problem.
	ProblemID int64 `db:"problem_id"`
	// contains filtered or unexported fields
}

ContestSolution represents connection for solutions.

func (ContestSolution) Clone

func (o ContestSolution) Clone() ContestSolution

Clone creates copy of contest solution.

func (ContestSolution) ObjectID

func (o ContestSolution) ObjectID() int64

ObjectID returns ID of object.

func (*ContestSolution) SetObjectID

func (o *ContestSolution) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestSolutionEvent

type ContestSolutionEvent struct {
	ContestSolution
	// contains filtered or unexported fields
}

ContestSolutionEvent represents solution event.

func (ContestSolutionEvent) EventID

func (e ContestSolutionEvent) EventID() int64

EventID returns id of this event.

func (ContestSolutionEvent) EventKind

func (e ContestSolutionEvent) EventKind() EventKind

EventKind returns type of this event.

func (ContestSolutionEvent) EventTime

func (e ContestSolutionEvent) EventTime() time.Time

EventTime returns time of this event.

func (ContestSolutionEvent) Object

Object returns event role edge.

func (ContestSolutionEvent) ObjectID

func (o ContestSolutionEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ContestSolutionEvent) SetEventAccountID

func (e *ContestSolutionEvent) SetEventAccountID(accountID int64)

func (*ContestSolutionEvent) SetEventID

func (e *ContestSolutionEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ContestSolutionEvent) SetEventKind

func (e *ContestSolutionEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ContestSolutionEvent) SetEventTime

func (e *ContestSolutionEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ContestSolutionEvent) SetObject

func (e *ContestSolutionEvent) SetObject(o ContestSolution)

SetObject sets event contest solution.

func (*ContestSolutionEvent) SetObjectID

func (o *ContestSolutionEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ContestSolutionStore

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

ContestSolutionStore represents a solution store.

func NewContestSolutionStore

func NewContestSolutionStore(
	db *gosql.DB, table, eventTable string,
) *ContestSolutionStore

NewContestSolutionStore creates a new instance of ContestSolutionStore.

func (*ContestSolutionStore) All

func (s *ContestSolutionStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ContestSolutionStore) Create

func (s *ContestSolutionStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ContestSolutionStore) DB

func (s *ContestSolutionStore) DB() *gosql.DB

DB returns store database.

func (*ContestSolutionStore) Delete

func (s *ContestSolutionStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ContestSolutionStore) Events

func (s *ContestSolutionStore) Events() db.EventROStore[E]

func (*ContestSolutionStore) Find

func (s *ContestSolutionStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ContestSolutionStore) FindByContest

func (s *ContestSolutionStore) FindByContest(
	ctx context.Context, contestID ...int64,
) (db.Rows[ContestSolution], error)

FindByContest returns solutions by contest ID.

func (*ContestSolutionStore) FindByParticipant

func (s *ContestSolutionStore) FindByParticipant(
	ctx context.Context, participantID ...int64,
) (db.Rows[ContestSolution], error)

FindByContest returns solutions by participant ID.

func (*ContestSolutionStore) FindOne

func (s *ContestSolutionStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ContestSolutionStore) Get

func (s *ContestSolutionStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ContestSolutionStore) Init

func (s *ContestSolutionStore) Init(ctx context.Context) error

func (*ContestSolutionStore) Objects

func (s *ContestSolutionStore) Objects() db.ObjectROStore[T]

func (*ContestSolutionStore) ReverseAll

func (s *ContestSolutionStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ContestSolutionStore) Sync

func (s *ContestSolutionStore) Sync(ctx context.Context) error

func (*ContestSolutionStore) TrySync

func (s *ContestSolutionStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ContestSolutionStore) Update

func (s *ContestSolutionStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type ContestStore

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

ContestStore represents store for contests.

func NewContestStore

func NewContestStore(
	db *gosql.DB, table, eventTable string,
) *ContestStore

NewContestStore creates a new instance of ContestStore.

func (*ContestStore) All

func (s *ContestStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ContestStore) Create

func (s *ContestStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ContestStore) DB

func (s *ContestStore) DB() *gosql.DB

DB returns store database.

func (*ContestStore) Delete

func (s *ContestStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ContestStore) Events

func (s *ContestStore) Events() db.EventROStore[E]

func (*ContestStore) Find

func (s *ContestStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ContestStore) FindOne

func (s *ContestStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ContestStore) Get

func (s *ContestStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ContestStore) Init

func (s *ContestStore) Init(ctx context.Context) error

func (*ContestStore) Objects

func (s *ContestStore) Objects() db.ObjectROStore[T]

func (*ContestStore) ReverseAll

func (s *ContestStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ContestStore) Sync

func (s *ContestStore) Sync(ctx context.Context) error

func (*ContestStore) TrySync

func (s *ContestStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ContestStore) Update

func (s *ContestStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type EventKind

type EventKind int8

EventKind represents kind of object event.

const (
	// CreateEvent means that this is event of object creation.
	CreateEvent EventKind = 1
	// DeleteEvent means that this is event of object deletion.
	DeleteEvent EventKind = 2
	// UpdateEvent means that this is event of object modification.
	UpdateEvent EventKind = 3
)

func (EventKind) String

func (t EventKind) String() string

String returns string representation of event.

type ExecuteReport

type ExecuteReport struct {
	Usage UsageReport `json:"usage"`
	Log   string      `json:"log"`
}

type File

type File struct {
	Status     FileStatus `db:"status"`
	ExpireTime NInt64     `db:"expire_time"`
	Path       string     `db:"path"`
	Meta       JSON       `db:"meta"`
	// contains filtered or unexported fields
}

File represents a file.

func (File) Clone

func (o File) Clone() File

Clone creates copy of file.

func (File) GetMeta

func (o File) GetMeta() (FileMeta, error)

func (File) ObjectID

func (o File) ObjectID() int64

ObjectID returns ID of object.

func (*File) SetMeta

func (o *File) SetMeta(config FileMeta) error

func (*File) SetObjectID

func (o *File) SetObjectID(id int64)

SetObjectID updates ID of object.

type FileEvent

type FileEvent struct {
	File
	// contains filtered or unexported fields
}

FileEvent represents a file event.

func (FileEvent) EventID

func (e FileEvent) EventID() int64

EventID returns id of this event.

func (FileEvent) EventKind

func (e FileEvent) EventKind() EventKind

EventKind returns type of this event.

func (FileEvent) EventTime

func (e FileEvent) EventTime() time.Time

EventTime returns time of this event.

func (FileEvent) Object

func (e FileEvent) Object() File

Object returns event file.

func (FileEvent) ObjectID

func (o FileEvent) ObjectID() int64

ObjectID returns ID of object.

func (*FileEvent) SetEventAccountID

func (e *FileEvent) SetEventAccountID(accountID int64)

func (*FileEvent) SetEventID

func (e *FileEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*FileEvent) SetEventKind

func (e *FileEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*FileEvent) SetEventTime

func (e *FileEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*FileEvent) SetObject

func (e *FileEvent) SetObject(o File)

SetObject sets event file.

func (*FileEvent) SetObjectID

func (o *FileEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type FileMeta

type FileMeta struct {
	Name string `json:"name,omitempty"`
	Size int64  `json:"size"`
	MD5  string `json:"md5"`
}

type FileStatus

type FileStatus int
const (
	PendingFile   FileStatus = 0
	AvailableFile FileStatus = 1
)

func (FileStatus) String

func (t FileStatus) String() string

String returns string representation.

type FileStore

type FileStore interface {
	Store[File, FileEvent]
}

func NewCachedFileStore

func NewCachedFileStore(
	db *gosql.DB, table, eventTable string,
) FileStore

NewCachedFileStore creates a new instance of FileStore.

func NewFileStore

func NewFileStore(
	db *gosql.DB, table, eventTable string,
) FileStore

newFileStore creates a new instance of FileStore.

type JSON

type JSON []byte

JSON represents json value.

func (JSON) Clone

func (v JSON) Clone() JSON

func (JSON) MarshalJSON

func (v JSON) MarshalJSON() ([]byte, error)

MarshalJSON marshals JSON.

func (*JSON) Scan

func (v *JSON) Scan(value any) error

Scan scans value.

func (*JSON) UnmarshalJSON

func (v *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON.

func (JSON) Value

func (v JSON) Value() (driver.Value, error)

Value returns value.

type JudgeSolutionTaskConfig

type JudgeSolutionTaskConfig struct {
	SolutionID   int64 `json:"solution_id"`
	EnablePoints bool  `json:"enable_points,omitempty"`
}

JudgeSolutionTaskConfig represets config for JudgeSolution.

func (JudgeSolutionTaskConfig) TaskKind

func (c JudgeSolutionTaskConfig) TaskKind() TaskKind

type JudgeSolutionTaskState

type JudgeSolutionTaskState struct {
	Stage string `json:"stage,omitempty"`
	Test  int    `json:"test,omitempty"`
}

type Lock

type Lock struct {
	ID         int64  `db:"id"`
	Name       string `db:"name"`
	Token      int64  `db:"token"`
	ExpireTime int64  `db:"expire_time"`
}

type LockGuard

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

func (*LockGuard) Expired

func (l *LockGuard) Expired() bool

func (*LockGuard) Ping

func (l *LockGuard) Ping(ctx context.Context) error

func (*LockGuard) Release

func (l *LockGuard) Release(ctx context.Context) error

type LockStore

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

func NewLockStore

func NewLockStore(db *gosql.DB, table string) *LockStore

func (*LockStore) AcquireByName

func (s *LockStore) AcquireByName(ctx context.Context, name string) (*LockGuard, error)

func (*LockStore) Get

func (s *LockStore) Get(ctx context.Context, id int64) (Lock, error)

func (*LockStore) GetByName

func (s *LockStore) GetByName(ctx context.Context, name string) (Lock, error)

type NInt64

type NInt64 int64

NInt64 represents nullable int64 with zero value means null value.

func (*NInt64) Scan

func (v *NInt64) Scan(value any) error

Scan scans value.

func (NInt64) Value

func (v NInt64) Value() (driver.Value, error)

Value returns value.

type NString

type NString string

NString represents nullable string with empty value means null value.

func (*NString) Scan

func (v *NString) Scan(value any) error

Scan scans value.

func (NString) Value

func (v NString) Value() (driver.Value, error)

Value returns value.

type ObjectEventPtr

type ObjectEventPtr[T any, E any] interface {
	db.EventPtr[E]
	SetEventTime(time.Time)
	EventKind() EventKind
	SetEventKind(EventKind)
	SetEventAccountID(int64)
	Object() T
	SetObject(T)
	ObjectID() int64
	SetObjectID(int64)
}

type ObjectPtr

type ObjectPtr[T any] interface {
	db.ObjectPtr[T]
	Cloner[T]
}

type Option

type Option[T any] struct {
	Value T
	Empty bool
}

func Empty

func Empty[T any]() Option[T]

func Value

func Value[T any](v T) Option[T]

func (Option[T]) OrElse

func (o Option[T]) OrElse(v T) T

type ParticipantKind

type ParticipantKind int
const (
	RegularParticipant   ParticipantKind = 1
	UpsolvingParticipant ParticipantKind = 2
	ManagerParticipant   ParticipantKind = 3
	ObserverParticipant  ParticipantKind = 4
)

func (ParticipantKind) MarshalText

func (k ParticipantKind) MarshalText() ([]byte, error)

func (ParticipantKind) String

func (k ParticipantKind) String() string

String returns string representation.

func (*ParticipantKind) UnmarshalText

func (k *ParticipantKind) UnmarshalText(data []byte) error

type Problem

type Problem struct {
	OwnerID    NInt64 `db:"owner_id"`
	Config     JSON   `db:"config"`
	Title      string `db:"title"`
	PackageID  NInt64 `db:"package_id"`
	CompiledID NInt64 `db:"compiled_id"`
	// contains filtered or unexported fields
}

Problem represents a problem.

func (Problem) Clone

func (o Problem) Clone() Problem

Clone creates copy of problem.

func (Problem) GetConfig

func (o Problem) GetConfig() (ProblemConfig, error)

func (Problem) ObjectID

func (o Problem) ObjectID() int64

ObjectID returns ID of object.

func (*Problem) SetConfig

func (o *Problem) SetConfig(config ProblemConfig) error

func (*Problem) SetObjectID

func (o *Problem) SetObjectID(id int64)

SetObjectID updates ID of object.

type ProblemConfig

type ProblemConfig struct {
	TimeLimit   int64 `json:"time_limit,omitempty"`
	MemoryLimit int64 `json:"memory_limit,omitempty"`
}

type ProblemEvent

type ProblemEvent struct {
	Problem
	// contains filtered or unexported fields
}

ProblemEvent represents a problem event.

func (ProblemEvent) EventID

func (e ProblemEvent) EventID() int64

EventID returns id of this event.

func (ProblemEvent) EventKind

func (e ProblemEvent) EventKind() EventKind

EventKind returns type of this event.

func (ProblemEvent) EventTime

func (e ProblemEvent) EventTime() time.Time

EventTime returns time of this event.

func (ProblemEvent) Object

func (e ProblemEvent) Object() Problem

Object returns event problem.

func (ProblemEvent) ObjectID

func (o ProblemEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ProblemEvent) SetEventAccountID

func (e *ProblemEvent) SetEventAccountID(accountID int64)

func (*ProblemEvent) SetEventID

func (e *ProblemEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ProblemEvent) SetEventKind

func (e *ProblemEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ProblemEvent) SetEventTime

func (e *ProblemEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ProblemEvent) SetObject

func (e *ProblemEvent) SetObject(o Problem)

SetObject sets event problem.

func (*ProblemEvent) SetObjectID

func (o *ProblemEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ProblemResource

type ProblemResource struct {
	ProblemID int64               `db:"problem_id"`
	Kind      ProblemResourceKind `db:"kind"`
	Config    JSON                `db:"config"`
	FileID    NInt64              `db:"file_id"`
	// contains filtered or unexported fields
}

ProblemResource represents a problem resource.

func (ProblemResource) Clone

func (o ProblemResource) Clone() ProblemResource

Clone creates copy of problem resource.

func (ProblemResource) ObjectID

func (o ProblemResource) ObjectID() int64

ObjectID returns ID of object.

func (ProblemResource) ScanConfig

func (o ProblemResource) ScanConfig(config ProblemResourceConfig) error

func (*ProblemResource) SetConfig

func (o *ProblemResource) SetConfig(config ProblemResourceConfig) error

SetConfig updates kind and config of task.

func (*ProblemResource) SetObjectID

func (o *ProblemResource) SetObjectID(id int64)

SetObjectID updates ID of object.

type ProblemResourceConfig

type ProblemResourceConfig interface {
	ProblemResourceKind() ProblemResourceKind
}

type ProblemResourceEvent

type ProblemResourceEvent struct {
	ProblemResource
	// contains filtered or unexported fields
}

ProblemResourceEvent represents a problem resource event.

func (ProblemResourceEvent) EventID

func (e ProblemResourceEvent) EventID() int64

EventID returns id of this event.

func (ProblemResourceEvent) EventKind

func (e ProblemResourceEvent) EventKind() EventKind

EventKind returns type of this event.

func (ProblemResourceEvent) EventTime

func (e ProblemResourceEvent) EventTime() time.Time

EventTime returns time of this event.

func (ProblemResourceEvent) Object

Object returns event problem resource.

func (ProblemResourceEvent) ObjectID

func (o ProblemResourceEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ProblemResourceEvent) SetEventAccountID

func (e *ProblemResourceEvent) SetEventAccountID(accountID int64)

func (*ProblemResourceEvent) SetEventID

func (e *ProblemResourceEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ProblemResourceEvent) SetEventKind

func (e *ProblemResourceEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ProblemResourceEvent) SetEventTime

func (e *ProblemResourceEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ProblemResourceEvent) SetObject

func (e *ProblemResourceEvent) SetObject(o ProblemResource)

SetObject sets event problem resource.

func (*ProblemResourceEvent) SetObjectID

func (o *ProblemResourceEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ProblemResourceKind

type ProblemResourceKind int
const (
	ProblemStatement         ProblemResourceKind = 1
	ProblemStatementResource ProblemResourceKind = 2
)

type ProblemResourceStore

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

ProblemResourceStore represents store for problem resources.

func NewProblemResourceStore

func NewProblemResourceStore(
	db *gosql.DB, table, eventTable string,
) *ProblemResourceStore

NewProblemResourceStore creates a new instance of ProblemResourceStore.

func (*ProblemResourceStore) All

func (s *ProblemResourceStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ProblemResourceStore) Create

func (s *ProblemResourceStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ProblemResourceStore) DB

func (s *ProblemResourceStore) DB() *gosql.DB

DB returns store database.

func (*ProblemResourceStore) Delete

func (s *ProblemResourceStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ProblemResourceStore) Events

func (s *ProblemResourceStore) Events() db.EventROStore[E]

func (*ProblemResourceStore) Find

func (s *ProblemResourceStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ProblemResourceStore) FindByProblem

func (s *ProblemResourceStore) FindByProblem(ctx context.Context, id int64) ([]ProblemResource, error)

func (*ProblemResourceStore) FindOne

func (s *ProblemResourceStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ProblemResourceStore) Get

func (s *ProblemResourceStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ProblemResourceStore) Init

func (s *ProblemResourceStore) Init(ctx context.Context) error

func (*ProblemResourceStore) Objects

func (s *ProblemResourceStore) Objects() db.ObjectROStore[T]

func (*ProblemResourceStore) ReverseAll

func (s *ProblemResourceStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ProblemResourceStore) Sync

func (s *ProblemResourceStore) Sync(ctx context.Context) error

func (*ProblemResourceStore) TrySync

func (s *ProblemResourceStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ProblemResourceStore) Update

func (s *ProblemResourceStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type ProblemStatementConfig

type ProblemStatementConfig struct {
	Locale      string `json:"locale"`
	Title       string `json:"title"`
	Legend      string `json:"legend,omitempty"`
	Input       string `json:"input,omitempty"`
	Output      string `json:"output,omitempty"`
	Notes       string `json:"notes,omitempty"`
	Scoring     string `json:"scoring,omitempty"`
	Interaction string `json:"interaction,omitempty"`
	// Samples contains problem sample tests.
	Samples []ProblemStatementSample `json:"samples,omitempty"`
}

func (ProblemStatementConfig) ProblemResourceKind

func (c ProblemStatementConfig) ProblemResourceKind() ProblemResourceKind

type ProblemStatementResourceConfig

type ProblemStatementResourceConfig struct {
	Locale string `json:"locale"`
	Name   string `json:"name"`
}

func (ProblemStatementResourceConfig) ProblemResourceKind

func (c ProblemStatementResourceConfig) ProblemResourceKind() ProblemResourceKind

type ProblemStatementSample

type ProblemStatementSample struct {
	Input  string `json:"input,omitempty"`
	Output string `json:"output,omitempty"`
}

type ProblemStore

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

ProblemStore represents store for problems.

func NewProblemStore

func NewProblemStore(
	db *gosql.DB, table, eventTable string,
) *ProblemStore

NewProblemStore creates a new instance of ProblemStore.

func (*ProblemStore) All

func (s *ProblemStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ProblemStore) Create

func (s *ProblemStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ProblemStore) DB

func (s *ProblemStore) DB() *gosql.DB

DB returns store database.

func (*ProblemStore) Delete

func (s *ProblemStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ProblemStore) Events

func (s *ProblemStore) Events() db.EventROStore[E]

func (*ProblemStore) Find

func (s *ProblemStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ProblemStore) FindOne

func (s *ProblemStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ProblemStore) Get

func (s *ProblemStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ProblemStore) Init

func (s *ProblemStore) Init(ctx context.Context) error

func (*ProblemStore) Objects

func (s *ProblemStore) Objects() db.ObjectROStore[T]

func (*ProblemStore) ReverseAll

func (s *ProblemStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ProblemStore) Sync

func (s *ProblemStore) Sync(ctx context.Context) error

func (*ProblemStore) TrySync

func (s *ProblemStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ProblemStore) Update

func (s *ProblemStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type RegularParticipantConfig

type RegularParticipantConfig struct {
	BeginTime NInt64 `json:"begin_time,omitempty"`
}

type Role

type Role struct {

	// Name contains role name.
	//
	// Name should be unique for all roles in the events.
	Name string `db:"name"`
	// contains filtered or unexported fields
}

Role represents a role.

func (Role) Clone

func (o Role) Clone() Role

Clone creates copy of role.

func (Role) IsBuiltIn

func (o Role) IsBuiltIn() bool

IsBuiltIn returns flag that role is built-in.

func (Role) ObjectID

func (o Role) ObjectID() int64

ObjectID returns ID of object.

func (*Role) SetObjectID

func (o *Role) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleEdge

type RoleEdge struct {

	// RoleID contains ID of parent role.
	RoleID int64 `db:"role_id" json:"role_id"`
	// ChildID contains ID of child role.
	ChildID int64 `db:"child_id" json:"child_id"`
	// contains filtered or unexported fields
}

RoleEdge represents connection for roles.

func (RoleEdge) Clone

func (o RoleEdge) Clone() RoleEdge

Clone creates copy of role edge.

func (RoleEdge) ObjectID

func (o RoleEdge) ObjectID() int64

ObjectID returns ID of object.

func (*RoleEdge) SetObjectID

func (o *RoleEdge) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleEdgeEvent

type RoleEdgeEvent struct {
	RoleEdge
	// contains filtered or unexported fields
}

RoleEdgeEvent represents role edge event.

func (RoleEdgeEvent) EventID

func (e RoleEdgeEvent) EventID() int64

EventID returns id of this event.

func (RoleEdgeEvent) EventKind

func (e RoleEdgeEvent) EventKind() EventKind

EventKind returns type of this event.

func (RoleEdgeEvent) EventTime

func (e RoleEdgeEvent) EventTime() time.Time

EventTime returns time of this event.

func (RoleEdgeEvent) Object

func (e RoleEdgeEvent) Object() RoleEdge

Object returns event role edge.

func (RoleEdgeEvent) ObjectID

func (o RoleEdgeEvent) ObjectID() int64

ObjectID returns ID of object.

func (*RoleEdgeEvent) SetEventAccountID

func (e *RoleEdgeEvent) SetEventAccountID(accountID int64)

func (*RoleEdgeEvent) SetEventID

func (e *RoleEdgeEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*RoleEdgeEvent) SetEventKind

func (e *RoleEdgeEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*RoleEdgeEvent) SetEventTime

func (e *RoleEdgeEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*RoleEdgeEvent) SetObject

func (e *RoleEdgeEvent) SetObject(o RoleEdge)

SetObject sets event role edge.

func (*RoleEdgeEvent) SetObjectID

func (o *RoleEdgeEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleEdgeStore

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

RoleEdgeStore represents a role edge store.

func NewRoleEdgeStore

func NewRoleEdgeStore(
	db *gosql.DB, table, eventTable string,
) *RoleEdgeStore

NewRoleEdgeStore creates a new instance of RoleEdgeStore.

func (*RoleEdgeStore) All

func (s *RoleEdgeStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*RoleEdgeStore) Create

func (s *RoleEdgeStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*RoleEdgeStore) DB

func (s *RoleEdgeStore) DB() *gosql.DB

DB returns store database.

func (*RoleEdgeStore) Delete

func (s *RoleEdgeStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*RoleEdgeStore) Events

func (s *RoleEdgeStore) Events() db.EventROStore[E]

func (*RoleEdgeStore) Find

func (s *RoleEdgeStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*RoleEdgeStore) FindByRole

func (s *RoleEdgeStore) FindByRole(id int64) ([]RoleEdge, error)

FindByRole returns edges by parent ID.

func (*RoleEdgeStore) FindOne

func (s *RoleEdgeStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*RoleEdgeStore) Get

func (s *RoleEdgeStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*RoleEdgeStore) Init

func (s *RoleEdgeStore) Init(ctx context.Context) error

func (*RoleEdgeStore) Objects

func (s *RoleEdgeStore) Objects() db.ObjectROStore[T]

func (*RoleEdgeStore) ReverseAll

func (s *RoleEdgeStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*RoleEdgeStore) Sync

func (s *RoleEdgeStore) Sync(ctx context.Context) error

func (*RoleEdgeStore) TrySync

func (s *RoleEdgeStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*RoleEdgeStore) Update

func (s *RoleEdgeStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type RoleEvent

type RoleEvent struct {
	Role
	// contains filtered or unexported fields
}

RoleEvent represents role event.

func (RoleEvent) EventID

func (e RoleEvent) EventID() int64

EventID returns id of this event.

func (RoleEvent) EventKind

func (e RoleEvent) EventKind() EventKind

EventKind returns type of this event.

func (RoleEvent) EventTime

func (e RoleEvent) EventTime() time.Time

EventTime returns time of this event.

func (RoleEvent) Object

func (e RoleEvent) Object() Role

Object returns event role.

func (RoleEvent) ObjectID

func (o RoleEvent) ObjectID() int64

ObjectID returns ID of object.

func (*RoleEvent) SetEventAccountID

func (e *RoleEvent) SetEventAccountID(accountID int64)

func (*RoleEvent) SetEventID

func (e *RoleEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*RoleEvent) SetEventKind

func (e *RoleEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*RoleEvent) SetEventTime

func (e *RoleEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*RoleEvent) SetObject

func (e *RoleEvent) SetObject(o Role)

SetObject sets event role.

func (*RoleEvent) SetObjectID

func (o *RoleEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleStore

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

RoleStore represents a role store.

func NewRoleStore

func NewRoleStore(
	db *gosql.DB, table, eventTable string,
) *RoleStore

NewRoleStore creates a new instance of RoleStore.

func (*RoleStore) All

func (s *RoleStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*RoleStore) Create

func (s *RoleStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*RoleStore) DB

func (s *RoleStore) DB() *gosql.DB

DB returns store database.

func (*RoleStore) Delete

func (s *RoleStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*RoleStore) Events

func (s *RoleStore) Events() db.EventROStore[E]

func (*RoleStore) Find

func (s *RoleStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*RoleStore) FindOne

func (s *RoleStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*RoleStore) Get

func (s *RoleStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*RoleStore) GetByName

func (s *RoleStore) GetByName(name string) (Role, error)

GetByName returns role by name.

If there is no role with specified name then sql.ErrNoRows will be returned.

func (*RoleStore) Init

func (s *RoleStore) Init(ctx context.Context) error

func (*RoleStore) Objects

func (s *RoleStore) Objects() db.ObjectROStore[T]

func (*RoleStore) ReverseAll

func (s *RoleStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*RoleStore) Sync

func (s *RoleStore) Sync(ctx context.Context) error

func (*RoleStore) TrySync

func (s *RoleStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*RoleStore) Update

func (s *RoleStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Scope

type Scope struct {
	AccountID int64  `db:"account_id"`
	OwnerID   NInt64 `db:"owner_id"`
	Title     string `db:"title"`
	// contains filtered or unexported fields
}

Scope represents a scope for users.

func (Scope) AccountKind

func (o Scope) AccountKind() AccountKind

AccountKind returns ScopeAccount kind.

func (Scope) Clone

func (o Scope) Clone() Scope

Clone creates copy of scope.

func (Scope) ObjectID

func (o Scope) ObjectID() int64

ObjectID returns ID of object.

func (*Scope) SetObjectID

func (o *Scope) SetObjectID(id int64)

SetObjectID updates ID of object.

type ScopeEvent

type ScopeEvent struct {
	Scope
	// contains filtered or unexported fields
}

ScopeEvent represents an scope event.

func (ScopeEvent) EventID

func (e ScopeEvent) EventID() int64

EventID returns id of this event.

func (ScopeEvent) EventKind

func (e ScopeEvent) EventKind() EventKind

EventKind returns type of this event.

func (ScopeEvent) EventTime

func (e ScopeEvent) EventTime() time.Time

EventTime returns time of this event.

func (ScopeEvent) Object

func (e ScopeEvent) Object() Scope

Object returns event scope.

func (ScopeEvent) ObjectID

func (o ScopeEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ScopeEvent) SetEventAccountID

func (e *ScopeEvent) SetEventAccountID(accountID int64)

func (*ScopeEvent) SetEventID

func (e *ScopeEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ScopeEvent) SetEventKind

func (e *ScopeEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ScopeEvent) SetEventTime

func (e *ScopeEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ScopeEvent) SetObject

func (e *ScopeEvent) SetObject(o Scope)

SetObject sets event scope.

func (*ScopeEvent) SetObjectID

func (o *ScopeEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ScopeStore

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

ScopeStore represents store for scopes.

func NewScopeStore

func NewScopeStore(
	db *gosql.DB, table, eventTable string,
) *ScopeStore

NewScopeStore creates a new instance of ScopeStore.

func (*ScopeStore) All

func (s *ScopeStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ScopeStore) Create

func (s *ScopeStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ScopeStore) DB

func (s *ScopeStore) DB() *gosql.DB

DB returns store database.

func (*ScopeStore) Delete

func (s *ScopeStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ScopeStore) Events

func (s *ScopeStore) Events() db.EventROStore[E]

func (*ScopeStore) Find

func (s *ScopeStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ScopeStore) FindOne

func (s *ScopeStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ScopeStore) Get

func (s *ScopeStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ScopeStore) GetByAccount

func (s *ScopeStore) GetByAccount(id int64) (Scope, error)

GetByAccount returns scope user by account id.

func (*ScopeStore) Init

func (s *ScopeStore) Init(ctx context.Context) error

func (*ScopeStore) Objects

func (s *ScopeStore) Objects() db.ObjectROStore[T]

func (*ScopeStore) ReverseAll

func (s *ScopeStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ScopeStore) Sync

func (s *ScopeStore) Sync(ctx context.Context) error

func (*ScopeStore) TrySync

func (s *ScopeStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ScopeStore) Update

func (s *ScopeStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type ScopeUser

type ScopeUser struct {
	AccountID    int64   `db:"account_id"`
	ScopeID      int64   `db:"scope_id"`
	Login        string  `db:"login"`
	PasswordHash string  `db:"password_hash"`
	PasswordSalt string  `db:"password_salt"`
	Title        NString `db:"title"`
	// contains filtered or unexported fields
}

ScopeUser contains common information about scope user.

func (ScopeUser) AccountKind

func (o ScopeUser) AccountKind() AccountKind

AccountKind returns ScopeUserAccount kind.

func (ScopeUser) Clone

func (o ScopeUser) Clone() ScopeUser

Clone creates copy of scope user.

func (ScopeUser) ObjectID

func (o ScopeUser) ObjectID() int64

ObjectID returns ID of object.

func (*ScopeUser) SetObjectID

func (o *ScopeUser) SetObjectID(id int64)

SetObjectID updates ID of object.

type ScopeUserEvent

type ScopeUserEvent struct {
	ScopeUser
	// contains filtered or unexported fields
}

ScopeUserEvent represents an scope user event.

func (ScopeUserEvent) EventID

func (e ScopeUserEvent) EventID() int64

EventID returns id of this event.

func (ScopeUserEvent) EventKind

func (e ScopeUserEvent) EventKind() EventKind

EventKind returns type of this event.

func (ScopeUserEvent) EventTime

func (e ScopeUserEvent) EventTime() time.Time

EventTime returns time of this event.

func (ScopeUserEvent) Object

func (e ScopeUserEvent) Object() ScopeUser

Object returns scope user.

func (ScopeUserEvent) ObjectID

func (o ScopeUserEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ScopeUserEvent) SetEventAccountID

func (e *ScopeUserEvent) SetEventAccountID(accountID int64)

func (*ScopeUserEvent) SetEventID

func (e *ScopeUserEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ScopeUserEvent) SetEventKind

func (e *ScopeUserEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ScopeUserEvent) SetEventTime

func (e *ScopeUserEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ScopeUserEvent) SetObject

func (e *ScopeUserEvent) SetObject(o ScopeUser)

SetObject sets event scope user.

func (*ScopeUserEvent) SetObjectID

func (o *ScopeUserEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ScopeUserStore

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

ScopeUserStore represents scope users store.

func NewScopeUserStore

func NewScopeUserStore(
	db *gosql.DB, table, eventTable, salt string,
) *ScopeUserStore

NewScopeUserStore creates new instance of scope user store.

func (*ScopeUserStore) All

func (s *ScopeUserStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*ScopeUserStore) CheckPassword

func (s *ScopeUserStore) CheckPassword(user ScopeUser, password string) bool

CheckPassword checks that passwords are the same.

func (*ScopeUserStore) Create

func (s *ScopeUserStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ScopeUserStore) DB

func (s *ScopeUserStore) DB() *gosql.DB

DB returns store database.

func (*ScopeUserStore) Delete

func (s *ScopeUserStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ScopeUserStore) Events

func (s *ScopeUserStore) Events() db.EventROStore[E]

func (*ScopeUserStore) Find

func (s *ScopeUserStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*ScopeUserStore) FindByScope

func (s *ScopeUserStore) FindByScope(scope int64) ([]ScopeUser, error)

FindByScope returns scope users by scope.

func (*ScopeUserStore) FindOne

func (s *ScopeUserStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*ScopeUserStore) Get

func (s *ScopeUserStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*ScopeUserStore) GetByAccount

func (s *ScopeUserStore) GetByAccount(id int64) (ScopeUser, error)

GetByAccount returns scope user by account id.

func (*ScopeUserStore) GetByScopeLogin

func (s *ScopeUserStore) GetByScopeLogin(scope int64, login string) (ScopeUser, error)

GetByScopeLogin returns scope user by scope and login.

func (*ScopeUserStore) Init

func (s *ScopeUserStore) Init(ctx context.Context) error

func (*ScopeUserStore) Objects

func (s *ScopeUserStore) Objects() db.ObjectROStore[T]

func (*ScopeUserStore) ReverseAll

func (s *ScopeUserStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*ScopeUserStore) SetPassword

func (s *ScopeUserStore) SetPassword(user *ScopeUser, password string) error

SetPassword modifies PasswordHash and PasswordSalt fields.

PasswordSalt will be replaced with random 16 byte string and PasswordHash will be calculated using password, salt and global salt.

func (*ScopeUserStore) Sync

func (s *ScopeUserStore) Sync(ctx context.Context) error

func (*ScopeUserStore) TrySync

func (s *ScopeUserStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*ScopeUserStore) Update

func (s *ScopeUserStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Session

type Session struct {

	// AccountID contains ID of account.
	AccountID int64 `db:"account_id"`
	// Secret contains secret string of session.
	Secret string `db:"secret"`
	// CreateTime contains time when session was created.
	CreateTime int64 `db:"create_time"`
	// ExpireTime contains time when session should be expired.
	ExpireTime int64 `db:"expire_time"`
	// RealIP contains real IP of user for created session.
	RealIP string `db:"real_ip"`
	// UserAgent contains user agent header for created session.
	UserAgent string `db:"user_agent"`
	// contains filtered or unexported fields
}

Session represents account session.

func (Session) Clone

func (o Session) Clone() Session

Clone creates copy of session.

func (Session) Cookie

func (o Session) Cookie() http.Cookie

Cookie returns cookie object.

func (*Session) GenerateSecret

func (o *Session) GenerateSecret() error

GenerateSecret generates a new value for session secret.

func (Session) ObjectID

func (o Session) ObjectID() int64

ObjectID returns ID of object.

func (*Session) SetObjectID

func (o *Session) SetObjectID(id int64)

SetObjectID updates ID of object.

type SessionEvent

type SessionEvent struct {
	Session
	// contains filtered or unexported fields
}

SessionEvent represents session event.

func (SessionEvent) EventID

func (e SessionEvent) EventID() int64

EventID returns id of this event.

func (SessionEvent) EventKind

func (e SessionEvent) EventKind() EventKind

EventKind returns type of this event.

func (SessionEvent) EventTime

func (e SessionEvent) EventTime() time.Time

EventTime returns time of this event.

func (SessionEvent) Object

func (e SessionEvent) Object() Session

Object returns session.

func (SessionEvent) ObjectID

func (o SessionEvent) ObjectID() int64

ObjectID returns ID of object.

func (*SessionEvent) SetEventAccountID

func (e *SessionEvent) SetEventAccountID(accountID int64)

func (*SessionEvent) SetEventID

func (e *SessionEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*SessionEvent) SetEventKind

func (e *SessionEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*SessionEvent) SetEventTime

func (e *SessionEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*SessionEvent) SetObject

func (e *SessionEvent) SetObject(o Session)

SetObject sets event session.

func (*SessionEvent) SetObjectID

func (o *SessionEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type SessionStore

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

SessionStore represents store for sessions.

func NewSessionStore

func NewSessionStore(
	db *gosql.DB, table, eventTable string,
) *SessionStore

NewSessionStore creates a new instance of SessionStore.

func (*SessionStore) All

func (s *SessionStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*SessionStore) Create

func (s *SessionStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*SessionStore) DB

func (s *SessionStore) DB() *gosql.DB

DB returns store database.

func (*SessionStore) Delete

func (s *SessionStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*SessionStore) Events

func (s *SessionStore) Events() db.EventROStore[E]

func (*SessionStore) Find

func (s *SessionStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*SessionStore) FindByAccount

func (s *SessionStore) FindByAccount(id int64) ([]Session, error)

FindByAccount returns sessions by account ID.

func (*SessionStore) FindOne

func (s *SessionStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*SessionStore) Get

func (s *SessionStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*SessionStore) GetByCookie

func (s *SessionStore) GetByCookie(cookie string) (Session, error)

GetByCookie returns session for specified cookie value.

func (*SessionStore) Init

func (s *SessionStore) Init(ctx context.Context) error

func (*SessionStore) Objects

func (s *SessionStore) Objects() db.ObjectROStore[T]

func (*SessionStore) ReverseAll

func (s *SessionStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*SessionStore) Sync

func (s *SessionStore) Sync(ctx context.Context) error

func (*SessionStore) TrySync

func (s *SessionStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*SessionStore) Update

func (s *SessionStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Setting

type Setting struct {
	Key   string `db:"key"`
	Value string `db:"value"`
	// contains filtered or unexported fields
}

Setting represents setting.

func (Setting) Clone

func (o Setting) Clone() Setting

Clone creates copy of setting.

func (Setting) ObjectID

func (o Setting) ObjectID() int64

ObjectID returns ID of object.

func (*Setting) SetObjectID

func (o *Setting) SetObjectID(id int64)

SetObjectID updates ID of object.

type SettingEvent

type SettingEvent struct {
	Setting
	// contains filtered or unexported fields
}

SettingEvent represents setting event.

func (SettingEvent) EventID

func (e SettingEvent) EventID() int64

EventID returns id of this event.

func (SettingEvent) EventKind

func (e SettingEvent) EventKind() EventKind

EventKind returns type of this event.

func (SettingEvent) EventTime

func (e SettingEvent) EventTime() time.Time

EventTime returns time of this event.

func (SettingEvent) Object

func (e SettingEvent) Object() Setting

Object returns event compiler.

func (SettingEvent) ObjectID

func (o SettingEvent) ObjectID() int64

ObjectID returns ID of object.

func (*SettingEvent) SetEventAccountID

func (e *SettingEvent) SetEventAccountID(accountID int64)

func (*SettingEvent) SetEventID

func (e *SettingEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*SettingEvent) SetEventKind

func (e *SettingEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*SettingEvent) SetEventTime

func (e *SettingEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*SettingEvent) SetObject

func (e *SettingEvent) SetObject(o Setting)

SetObject sets event setting.

func (*SettingEvent) SetObjectID

func (o *SettingEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type SettingStore

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

SettingStore represents store for settings.

func NewSettingStore

func NewSettingStore(db *gosql.DB, table, eventTable string) *SettingStore

NewSettingStore creates a new instance of SettingStore.

func (*SettingStore) All

func (s *SettingStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*SettingStore) Create

func (s *SettingStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*SettingStore) DB

func (s *SettingStore) DB() *gosql.DB

DB returns store database.

func (*SettingStore) Delete

func (s *SettingStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*SettingStore) Events

func (s *SettingStore) Events() db.EventROStore[E]

func (*SettingStore) Find

func (s *SettingStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*SettingStore) FindOne

func (s *SettingStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*SettingStore) Get

func (s *SettingStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*SettingStore) GetBool

func (s *SettingStore) GetBool(key string) (Option[bool], error)

func (*SettingStore) GetByKey

func (s *SettingStore) GetByKey(key string) (Setting, error)

GetByKey returns setting by specified key.

func (*SettingStore) GetInt64

func (s *SettingStore) GetInt64(key string) (Option[int64], error)

func (*SettingStore) Init

func (s *SettingStore) Init(ctx context.Context) error

func (*SettingStore) Objects

func (s *SettingStore) Objects() db.ObjectROStore[T]

func (*SettingStore) ReverseAll

func (s *SettingStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*SettingStore) Sync

func (s *SettingStore) Sync(ctx context.Context) error

func (*SettingStore) TrySync

func (s *SettingStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*SettingStore) Update

func (s *SettingStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Solution

type Solution struct {
	ProblemID  int64   `db:"problem_id"`
	CompilerID int64   `db:"compiler_id"`
	AuthorID   int64   `db:"author_id"`
	Report     JSON    `db:"report"`
	CreateTime int64   `db:"create_time"`
	Content    NString `db:"content"`
	ContentID  NInt64  `db:"content_id"`
	// contains filtered or unexported fields
}

Solution represents a solution.

func (Solution) Clone

func (o Solution) Clone() Solution

Clone creates copy of solution.

func (Solution) GetReport

func (o Solution) GetReport() (*SolutionReport, error)

GetReport returns solution report.

func (Solution) ObjectID

func (o Solution) ObjectID() int64

ObjectID returns ID of object.

func (*Solution) SetObjectID

func (o *Solution) SetObjectID(id int64)

SetObjectID updates ID of object.

func (*Solution) SetReport

func (o *Solution) SetReport(report *SolutionReport) error

SetReport sets serialized report to solution.

type SolutionEvent

type SolutionEvent struct {
	Solution
	// contains filtered or unexported fields
}

SolutionEvent represents a solution event.

func (SolutionEvent) EventID

func (e SolutionEvent) EventID() int64

EventID returns id of this event.

func (SolutionEvent) EventKind

func (e SolutionEvent) EventKind() EventKind

EventKind returns type of this event.

func (SolutionEvent) EventTime

func (e SolutionEvent) EventTime() time.Time

EventTime returns time of this event.

func (SolutionEvent) Object

func (e SolutionEvent) Object() Solution

Object returns event solution.

func (SolutionEvent) ObjectID

func (o SolutionEvent) ObjectID() int64

ObjectID returns ID of object.

func (*SolutionEvent) SetEventAccountID

func (e *SolutionEvent) SetEventAccountID(accountID int64)

func (*SolutionEvent) SetEventID

func (e *SolutionEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*SolutionEvent) SetEventKind

func (e *SolutionEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*SolutionEvent) SetEventTime

func (e *SolutionEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*SolutionEvent) SetObject

func (e *SolutionEvent) SetObject(o Solution)

SetObject sets event solution.

func (*SolutionEvent) SetObjectID

func (o *SolutionEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type SolutionReport

type SolutionReport struct {
	Verdict  Verdict        `json:"verdict"`
	Usage    UsageReport    `json:"usage"`
	Compiler *ExecuteReport `json:"compiler,omitempty"`
	Tests    []TestReport   `json:"tests,omitempty"`
	Points   *float64       `json:"points,omitempty"`
}

type SolutionStore

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

SolutionStore represents store for solutions.

func NewSolutionStore

func NewSolutionStore(
	db *gosql.DB, table, eventTable string,
) *SolutionStore

NewSolutionStore creates a new instance of SolutionStore.

func (*SolutionStore) All

func (s *SolutionStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*SolutionStore) Create

func (s *SolutionStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*SolutionStore) DB

func (s *SolutionStore) DB() *gosql.DB

DB returns store database.

func (*SolutionStore) Delete

func (s *SolutionStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*SolutionStore) Events

func (s *SolutionStore) Events() db.EventROStore[E]

func (*SolutionStore) Find

func (s *SolutionStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*SolutionStore) FindByProblem

func (s *SolutionStore) FindByProblem(id int64) ([]Solution, error)

func (*SolutionStore) FindOne

func (s *SolutionStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*SolutionStore) Get

func (s *SolutionStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*SolutionStore) GetEventStore

func (s *SolutionStore) GetEventStore() db.EventStore[SolutionEvent, *SolutionEvent]

func (*SolutionStore) Init

func (s *SolutionStore) Init(ctx context.Context) error

func (*SolutionStore) Objects

func (s *SolutionStore) Objects() db.ObjectROStore[T]

func (*SolutionStore) ReverseAll

func (s *SolutionStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*SolutionStore) Sync

func (s *SolutionStore) Sync(ctx context.Context) error

func (*SolutionStore) TrySync

func (s *SolutionStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*SolutionStore) Update

func (s *SolutionStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type StandingsKind

type StandingsKind int
const (
	DisabledStandings StandingsKind = 0
	ICPCStandings     StandingsKind = 1
	IOIStandings      StandingsKind = 2
)

func (StandingsKind) MarshalText

func (v StandingsKind) MarshalText() ([]byte, error)

func (StandingsKind) String

func (v StandingsKind) String() string

func (*StandingsKind) UnmarshalText

func (v *StandingsKind) UnmarshalText(data []byte) error

type Store

type Store[T any, E any] interface {
	// DB should return database connection for specified store.
	DB() *gosql.DB
	Objects() db.ObjectROStore[T]
	Events() db.EventROStore[E]
	// Get should return object with speficied ID.
	Get(context.Context, int64) (T, error)
	// Create should create object and update `object.ID` on success.
	Create(context.Context, *T) error
	// Update should update object fields with specified `object.ID`.
	Update(context.Context, T) error
	// Delete should delete object with speficied ID.
	Delete(context.Context, int64) error
}

Store represents store for objects.

type Task

type Task struct {
	Kind       TaskKind   `db:"kind"`
	Config     JSON       `db:"config"`
	Status     TaskStatus `db:"status"`
	State      JSON       `db:"state"`
	ExpireTime NInt64     `db:"expire_time"`
	// contains filtered or unexported fields
}

Task represents async task.

func (Task) Clone

func (o Task) Clone() Task

Clone create copy of task.

func (Task) ObjectID

func (o Task) ObjectID() int64

ObjectID returns ID of object.

func (Task) ScanConfig

func (o Task) ScanConfig(config TaskConfig) error

func (Task) ScanState

func (o Task) ScanState(state any) error

func (*Task) SetConfig

func (o *Task) SetConfig(config TaskConfig) error

SetConfig updates kind and config of task.

func (*Task) SetObjectID

func (o *Task) SetObjectID(id int64)

SetObjectID updates ID of object.

func (*Task) SetState

func (o *Task) SetState(state any) error

type TaskConfig

type TaskConfig interface {
	TaskKind() TaskKind
}

type TaskEvent

type TaskEvent struct {
	Task
	// contains filtered or unexported fields
}

TaskEvent represents task event.

func (TaskEvent) EventID

func (e TaskEvent) EventID() int64

EventID returns id of this event.

func (TaskEvent) EventKind

func (e TaskEvent) EventKind() EventKind

EventKind returns type of this event.

func (TaskEvent) EventTime

func (e TaskEvent) EventTime() time.Time

EventTime returns time of this event.

func (TaskEvent) Object

func (e TaskEvent) Object() Task

Object returns task.

func (TaskEvent) ObjectID

func (o TaskEvent) ObjectID() int64

ObjectID returns ID of object.

func (*TaskEvent) SetEventAccountID

func (e *TaskEvent) SetEventAccountID(accountID int64)

func (*TaskEvent) SetEventID

func (e *TaskEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*TaskEvent) SetEventKind

func (e *TaskEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*TaskEvent) SetEventTime

func (e *TaskEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*TaskEvent) SetObject

func (e *TaskEvent) SetObject(o Task)

SetObject sets event task.

func (*TaskEvent) SetObjectID

func (o *TaskEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type TaskKind

type TaskKind int

TaskKind represents kind of task.

const (
	// JudgeSolutionTask represents judge solution task.
	JudgeSolutionTask TaskKind = 1
	// UpdateProblemPackageTask represents task for update problem package.
	UpdateProblemPackageTask TaskKind = 2
)

func (TaskKind) MarshalText

func (t TaskKind) MarshalText() ([]byte, error)

MarshalText marshals kind to text.

func (TaskKind) String

func (t TaskKind) String() string

String returns string representation.

type TaskStatus

type TaskStatus int

TaskStatus represents status of task.

const (
	// QueuedTask means that task in queue and should be processed.
	QueuedTask TaskStatus = 0
	// RunningTask means that task already in processing.
	RunningTask TaskStatus = 1
	// SucceededTask means that task is processed with success.
	SucceededTask TaskStatus = 2
	// FailedTask means that task is processed with failure.
	FailedTask TaskStatus = 3
)

func (TaskStatus) MarshalText

func (t TaskStatus) MarshalText() ([]byte, error)

MarshalText marshals status to text.

func (TaskStatus) String

func (t TaskStatus) String() string

String returns string representation.

type TaskStore

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

TaskStore represents store for tasks.

func NewTaskStore

func NewTaskStore(
	db *gosql.DB, table, eventTable string,
) *TaskStore

NewTaskStore creates a new instance of TaskStore.

func (*TaskStore) All

func (s *TaskStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*TaskStore) Create

func (s *TaskStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*TaskStore) DB

func (s *TaskStore) DB() *gosql.DB

DB returns store database.

func (*TaskStore) Delete

func (s *TaskStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*TaskStore) Events

func (s *TaskStore) Events() db.EventROStore[E]

func (*TaskStore) Find

func (s *TaskStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*TaskStore) FindByProblem

func (s *TaskStore) FindByProblem(id int64) ([]Task, error)

func (*TaskStore) FindBySolution

func (s *TaskStore) FindBySolution(id int64) ([]Task, error)

FindBySolution returns a list of tasks by specified solution.

func (*TaskStore) FindOne

func (s *TaskStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*TaskStore) Get

func (s *TaskStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*TaskStore) Init

func (s *TaskStore) Init(ctx context.Context) error

func (*TaskStore) Objects

func (s *TaskStore) Objects() db.ObjectROStore[T]

func (*TaskStore) PopQueued

func (s *TaskStore) PopQueued(
	ctx context.Context,
	duration time.Duration,
	filter func(TaskKind) bool,
) (Task, error)

PopQueued pops queued action from the events and sets running status.

Note that events is not synchronized after tasks is popped.

func (*TaskStore) ReverseAll

func (s *TaskStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*TaskStore) Sync

func (s *TaskStore) Sync(ctx context.Context) error

func (*TaskStore) TrySync

func (s *TaskStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*TaskStore) Update

func (s *TaskStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type TestReport

type TestReport struct {
	Verdict    Verdict        `json:"verdict"`
	Usage      UsageReport    `json:"usage"`
	Checker    *ExecuteReport `json:"checker,omitempty"`
	Interactor *ExecuteReport `json:"interactor,omitempty"`
	Points     *float64       `json:"points,omitempty"`
}

type Token

type Token struct {
	AccountID  int64     `db:"account_id"`
	Secret     string    `db:"secret"`
	Kind       TokenKind `db:"kind"`
	Config     JSON      `db:"config"`
	CreateTime int64     `db:"create_time"`
	ExpireTime int64     `db:"expire_time"`
	// contains filtered or unexported fields
}

Token represents a token.

func (Token) Clone

func (o Token) Clone() Token

Clone creates copy of scope.

func (*Token) GenerateSecret

func (o *Token) GenerateSecret() error

GenerateSecret generates a new value for token secret.

func (Token) ObjectID

func (o Token) ObjectID() int64

ObjectID returns ID of object.

func (Token) ScanConfig

func (o Token) ScanConfig(config TokenConfig) error

func (*Token) SetConfig

func (o *Token) SetConfig(config TokenConfig) error

SetConfig updates kind and config of token.

func (*Token) SetObjectID

func (o *Token) SetObjectID(id int64)

SetObjectID updates ID of object.

type TokenConfig

type TokenConfig interface {
	TokenKind() TokenKind
}

type TokenEvent

type TokenEvent struct {
	Token
	// contains filtered or unexported fields
}

TokenEvent represents a token event.

func (TokenEvent) EventID

func (e TokenEvent) EventID() int64

EventID returns id of this event.

func (TokenEvent) EventKind

func (e TokenEvent) EventKind() EventKind

EventKind returns type of this event.

func (TokenEvent) EventTime

func (e TokenEvent) EventTime() time.Time

EventTime returns time of this event.

func (TokenEvent) Object

func (e TokenEvent) Object() Token

Object returns event temporary token.

func (TokenEvent) ObjectID

func (o TokenEvent) ObjectID() int64

ObjectID returns ID of object.

func (*TokenEvent) SetEventAccountID

func (e *TokenEvent) SetEventAccountID(accountID int64)

func (*TokenEvent) SetEventID

func (e *TokenEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*TokenEvent) SetEventKind

func (e *TokenEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*TokenEvent) SetEventTime

func (e *TokenEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*TokenEvent) SetObject

func (e *TokenEvent) SetObject(o Token)

SetObject sets event temporary token.

func (*TokenEvent) SetObjectID

func (o *TokenEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type TokenKind

type TokenKind int
const (
	ConfirmEmailToken  TokenKind = 1
	ResetPasswordToken TokenKind = 2
)

type TokenStore

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

TokenStore represents store for tokens.

func NewTokenStore

func NewTokenStore(
	db *gosql.DB, table, eventTable string,
) *TokenStore

NewTokenStore creates a new instance of TokenStore.

func (*TokenStore) Create

func (s *TokenStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*TokenStore) DB

func (s *TokenStore) DB() *gosql.DB

DB returns store database.

func (*TokenStore) Delete

func (s *TokenStore) Delete(ctx context.Context, id int64) error

Delete deletes object with specified ID.

func (*TokenStore) Events

func (s *TokenStore) Events() db.EventROStore[E]

func (*TokenStore) Find

func (s *TokenStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*TokenStore) FindOne

func (s *TokenStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*TokenStore) Get

func (s *TokenStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*TokenStore) Objects

func (s *TokenStore) Objects() db.ObjectROStore[T]

func (*TokenStore) Update

func (s *TokenStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type UpdateProblemPackageTaskConfig

type UpdateProblemPackageTaskConfig struct {
	ProblemID int64 `json:"problem_id"`
	FileID    int64 `json:"file_id"`
	Compile   bool  `json:"compile"`
}

UpdateProblemPackageTaskConfig represets config for JudgeSolution.

func (UpdateProblemPackageTaskConfig) TaskKind

type UpdateProblemPackageTaskState

type UpdateProblemPackageTaskState struct {
	Error string `json:"error,omitempty"`
}

type UsageReport

type UsageReport struct {
	Time   int64 `json:"time,omitempty"`
	Memory int64 `json:"memory,omitempty"`
}

type User

type User struct {
	AccountID    int64      `db:"account_id"`
	Login        string     `db:"login"`
	Status       UserStatus `db:"status"`
	PasswordHash string     `db:"password_hash"`
	PasswordSalt string     `db:"password_salt"`
	Email        NString    `db:"email"`
	FirstName    NString    `db:"first_name"`
	LastName     NString    `db:"last_name"`
	MiddleName   NString    `db:"middle_name"`
	// contains filtered or unexported fields
}

User contains common information about user.

func (User) AccountKind

func (o User) AccountKind() AccountKind

AccountKind returns UserAccount kind.

func (User) Clone

func (o User) Clone() User

Clone creates copy of user.

func (User) ObjectID

func (o User) ObjectID() int64

ObjectID returns ID of object.

func (*User) SetObjectID

func (o *User) SetObjectID(id int64)

SetObjectID updates ID of object.

type UserEvent

type UserEvent struct {
	User
	// contains filtered or unexported fields
}

UserEvent represents an user event.

func (UserEvent) EventID

func (e UserEvent) EventID() int64

EventID returns id of this event.

func (UserEvent) EventKind

func (e UserEvent) EventKind() EventKind

EventKind returns type of this event.

func (UserEvent) EventTime

func (e UserEvent) EventTime() time.Time

EventTime returns time of this event.

func (UserEvent) Object

func (e UserEvent) Object() User

Object returns user.

func (UserEvent) ObjectID

func (o UserEvent) ObjectID() int64

ObjectID returns ID of object.

func (*UserEvent) SetEventAccountID

func (e *UserEvent) SetEventAccountID(accountID int64)

func (*UserEvent) SetEventID

func (e *UserEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*UserEvent) SetEventKind

func (e *UserEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*UserEvent) SetEventTime

func (e *UserEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*UserEvent) SetObject

func (e *UserEvent) SetObject(o User)

SetObject sets event user.

func (*UserEvent) SetObjectID

func (o *UserEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type UserStatus

type UserStatus int
const (
	PendingUser UserStatus = 0
	ActiveUser  UserStatus = 1
	BlockedUser UserStatus = 2
)

func (UserStatus) String

func (t UserStatus) String() string

String returns string representation.

type UserStore

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

UserStore represents users store.

func NewUserStore

func NewUserStore(
	db *gosql.DB, table, eventTable, salt string,
) *UserStore

NewUserStore creates new instance of user store.

func (*UserStore) All

func (s *UserStore) All(ctx context.Context, limit int) (db.Rows[T], error)

All returns all objects contained by this store.

func (*UserStore) CheckPassword

func (s *UserStore) CheckPassword(user User, password string) bool

CheckPassword checks that passwords are the same.

func (*UserStore) Create

func (s *UserStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*UserStore) DB

func (s *UserStore) DB() *gosql.DB

DB returns store database.

func (*UserStore) Delete

func (s *UserStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*UserStore) Events

func (s *UserStore) Events() db.EventROStore[E]

func (*UserStore) Find

func (s *UserStore) Find(
	ctx context.Context, options ...db.FindObjectsOption,
) (db.Rows[T], error)

Find finds objects with specified query.

func (*UserStore) FindOne

func (s *UserStore) FindOne(
	ctx context.Context, options ...db.FindObjectsOption,
) (T, error)

FindOne finds one object with specified query.

func (*UserStore) Get

func (s *UserStore) Get(ctx context.Context, id int64) (T, error)

Get returns object by id.

Returns sql.ErrNoRows if object does not exist.

func (*UserStore) GetByAccount

func (s *UserStore) GetByAccount(id int64) (User, error)

GetByAccount returns user by account id.

func (*UserStore) GetByLogin

func (s *UserStore) GetByLogin(login string) (User, error)

GetByLogin returns user by login.

func (*UserStore) Init

func (s *UserStore) Init(ctx context.Context) error

func (*UserStore) Objects

func (s *UserStore) Objects() db.ObjectROStore[T]

func (*UserStore) ReverseAll

func (s *UserStore) ReverseAll(ctx context.Context, limit int) (db.Rows[T], error)

ReverseAll returns all objects contained by this store.

func (*UserStore) SetPassword

func (s *UserStore) SetPassword(user *User, password string) error

SetPassword modifies PasswordHash and PasswordSalt fields.

PasswordSalt will be replaced with random 16 byte string and PasswordHash will be calculated using password, salt and global salt.

func (*UserStore) Sync

func (s *UserStore) Sync(ctx context.Context) error

func (*UserStore) TrySync

func (s *UserStore) TrySync(ctx context.Context) error

TrySync updates store cache only when needed.

func (*UserStore) Update

func (s *UserStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Verdict

type Verdict int
const (
	// Accepted means that solution is correct.
	Accepted Verdict = 1
	// Rejected means that solutios is rejected.
	Rejected Verdict = 2
	// CompilationError means that solution can not compiled.
	CompilationError Verdict = 3
	// TimeLimitExceeded means that solution uses more time than allowed.
	TimeLimitExceeded Verdict = 4
	// MemoryLimitExceeded means that solution uses more memory than allowed.
	MemoryLimitExceeded Verdict = 5
	// RuntimeError means that solution runs incorrectly.
	RuntimeError Verdict = 6
	// WrongAnswer means that solution is incorrect.
	WrongAnswer Verdict = 7
	// PresentationError means that solution output is incorrect.
	PresentationError Verdict = 8
	// PartiallyAccepted means that solution is partially accepted.
	PartiallyAccepted Verdict = 9
	// Failed means that solution checker is failed.
	Failed Verdict = 10
)

func (Verdict) MarshalText

func (v Verdict) MarshalText() ([]byte, error)

func (Verdict) String

func (v Verdict) String() string

func (*Verdict) UnmarshalText

func (v *Verdict) UnmarshalText(data []byte) error

type Visit

type Visit struct {
	ID        int64  `db:"id"`
	Time      int64  `db:"time"`
	AccountID NInt64 `db:"account_id"`
	SessionID NInt64 `db:"session_id"`
	Host      string `db:"host"`
	Protocol  string `db:"protocol"`
	Method    string `db:"method"`
	UserAgent string `db:"user_agent"`
	Path      string `db:"path"`
	RealIP    string `db:"real_ip"`
	Status    int    `db:"status"`
}

Visit represents user visit.

func (Visit) EventID

func (o Visit) EventID() int64

EventID returns ID of visit.

func (Visit) EventTime

func (o Visit) EventTime() time.Time

EventTime return time of visit.

func (*Visit) SetEventID

func (o *Visit) SetEventID(id int64)

SetEventID sets ID of visit.

type VisitStore

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

VisitStore represents visit store.

func NewVisitStore

func NewVisitStore(dbConn *gosql.DB, table string) *VisitStore

NewVisitStore creates a new instance of ViewStore.

func (*VisitStore) Create

func (s *VisitStore) Create(ctx context.Context, visit *Visit) error

Create creates a new visit in the events.

func (*VisitStore) MakeFromContext

func (s *VisitStore) MakeFromContext(c echo.Context) Visit

MakeFromContext creates Visit from context.

Jump to

Keyboard shortcuts

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