managers

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: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountContext

type AccountContext struct {
	Account       *models.Account
	User          *models.User
	ScopeUser     *models.ScopeUser
	Permissions   PermissionSet
	GroupAccounts []models.Account
	// contains filtered or unexported fields
}

func (*AccountContext) Deadline

func (c *AccountContext) Deadline() (time.Time, bool)

func (*AccountContext) Done

func (c *AccountContext) Done() <-chan struct{}

func (*AccountContext) Err

func (c *AccountContext) Err() error

func (*AccountContext) HasPermission

func (c *AccountContext) HasPermission(name string) bool

func (*AccountContext) Value

func (c *AccountContext) Value(key any) any

type AccountManager

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

func NewAccountManager

func NewAccountManager(core *core.Core) *AccountManager

func (*AccountManager) MakeContext

func (m *AccountManager) MakeContext(ctx context.Context, account *models.Account) (*AccountContext, error)

type BuildStandingsOptions

type BuildStandingsOptions struct {
	OnlyOfficial bool
	IgnoreFreeze bool
}

type ContestContext

type ContestContext struct {
	*AccountContext
	Contest       models.Contest
	ContestConfig models.ContestConfig
	Participants  []models.ContestParticipant
	Permissions   PermissionSet
	Stage         ContestStage
	Now           time.Time
	// contains filtered or unexported fields
}

func (*ContestContext) GetEffectiveParticipant

func (c *ContestContext) GetEffectiveParticipant() *models.ContestParticipant

func (*ContestContext) GetEffectivePermissions

func (c *ContestContext) GetEffectivePermissions() PermissionSet

func (*ContestContext) HasEffectivePermission

func (c *ContestContext) HasEffectivePermission(name string) bool

func (*ContestContext) HasPermission

func (c *ContestContext) HasPermission(name string) bool

func (*ContestContext) SetEffectiveParticipant

func (c *ContestContext) SetEffectiveParticipant(id int64)

type ContestManager

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

func NewContestManager

func NewContestManager(core *core.Core) *ContestManager

func (*ContestManager) BuildContext

func (m *ContestManager) BuildContext(ctx *AccountContext, contest models.Contest) (*ContestContext, error)

type ContestStage

type ContestStage int
const (
	ContestNotPlanned ContestStage = iota
	ContestNotStarted
	ContestStarted
	ContestFinished
)

type ContestStandings

type ContestStandings struct {
	Columns []ContestStandingsColumn
	Rows    []ContestStandingsRow
	Frozen  bool
}

type ContestStandingsCell

type ContestStandingsCell struct {
	Column  int
	Verdict models.Verdict
	Points  float64
	Attempt int
	Time    int64
}

type ContestStandingsColumn

type ContestStandingsColumn struct {
	Problem           models.ContestProblem
	TotalSolutions    int
	AcceptedSolutions int
}

type ContestStandingsManager

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

func NewContestStandingsManager

func NewContestStandingsManager(core *core.Core) *ContestStandingsManager

func (*ContestStandingsManager) BuildStandings

func (m *ContestStandingsManager) BuildStandings(
	ctx *ContestContext, options BuildStandingsOptions,
) (*ContestStandings, error)

type ContestStandingsRow

type ContestStandingsRow struct {
	Participant models.ContestParticipant
	Cells       []ContestStandingsCell
	Score       float64
	Penalty     *int64
	Place       int
}

type FileManager

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

func NewFileManager

func NewFileManager(c *core.Core) *FileManager

func (*FileManager) ConfirmUploadFile

func (m *FileManager) ConfirmUploadFile(
	ctx context.Context, file *models.File,
) error

func (*FileManager) DeleteFile

func (m *FileManager) DeleteFile(ctx context.Context, id int64) error

func (*FileManager) DownloadFile

func (m *FileManager) DownloadFile(
	ctx context.Context, id int64,
) (io.ReadCloser, error)

func (*FileManager) UploadFile

func (m *FileManager) UploadFile(
	ctx context.Context, fileReader *FileReader,
) (models.File, error)

UploadFile adds file to file storage and starts upload.

You shold call ConfirmUploadFile for marking file available.

type FileReader

type FileReader struct {
	Name   string
	Size   int64
	Reader io.ReadSeeker
}

func NewFileReader

func NewFileReader(file *os.File) *FileReader

func NewMultipartFileReader

func NewMultipartFileReader(file *multipart.FileHeader) (*FileReader, error)

func (*FileReader) Close

func (f *FileReader) Close() error

type FileStorage

type FileStorage interface {
	GeneratePath(context.Context) (string, error)
	ReadFile(context.Context, string) (io.ReadCloser, error)
	WriteFile(context.Context, string, io.ReadSeeker) (models.FileMeta, error)
	DeleteFile(context.Context, string) error
}

type LocalStorage

type LocalStorage struct {
	Dir string
}

func (*LocalStorage) DeleteFile

func (s *LocalStorage) DeleteFile(ctx context.Context, filePath string) error

func (*LocalStorage) GeneratePath

func (s *LocalStorage) GeneratePath(ctx context.Context) (string, error)

func (*LocalStorage) ReadFile

func (s *LocalStorage) ReadFile(ctx context.Context, filePath string) (io.ReadCloser, error)

func (*LocalStorage) WriteFile

func (s *LocalStorage) WriteFile(ctx context.Context, filePath string, file io.ReadSeeker) (models.FileMeta, error)

type PermissionSet

type PermissionSet map[string]struct{}

func (PermissionSet) AddPermission

func (p PermissionSet) AddPermission(names ...string)

func (PermissionSet) Clone

func (p PermissionSet) Clone() PermissionSet

func (PermissionSet) HasPermission

func (p PermissionSet) HasPermission(name string) bool

type Permissions

type Permissions interface {
	HasPermission(name string) bool
}

type S3Storage

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

func (*S3Storage) DeleteFile

func (s *S3Storage) DeleteFile(ctx context.Context, filePath string) error

func (*S3Storage) GeneratePath

func (s *S3Storage) GeneratePath(ctx context.Context) (string, error)

func (*S3Storage) ReadFile

func (s *S3Storage) ReadFile(ctx context.Context, filePath string) (io.ReadCloser, error)

func (*S3Storage) WriteFile

func (s *S3Storage) WriteFile(ctx context.Context, filePath string, file io.ReadSeeker) (models.FileMeta, error)

type SolutionManager

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

func NewSolutionManager

func NewSolutionManager(core *core.Core, files *FileManager) *SolutionManager

Jump to

Keyboard shortcuts

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