srvc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MaxSubmLengthKB = 64

Variables

View Source
var ErrInternal = srvcerror.ErrInternal
View Source
var ErrInvalidProgLang = srvcerror.New(
	"invalid_programming_language",
	"Norādīta programmēšanas valoda nav iespējota.",
).SetHttpStatusCode(http.StatusBadRequest)
View Source
var ErrSubmTooLong = srvcerror.New(
	"subm_too_long",
	fmt.Sprintf("Maksimālais koda garums ir %d KB.", MaxSubmLengthKB),
).SetHttpStatusCode(http.StatusBadRequest)
View Source
var ErrSubmissionNotFound = srvcerror.New(
	"submission_not_found",
	"Atbilstošais iesūtījums netika atrasts",
).SetHttpStatusCode(http.StatusNotFound)
View Source
var ErrUserNotFound = srvcerror.New(
	"user_not_found",
	"Norādītais lietotājs netika atrasts.",
).SetHttpStatusCode(http.StatusNotFound)

Functions

func NewSubmSrvc

func NewSubmSrvc(
	userSrvc usersrvc.UserService,
	taskSrvc tasksrvc.TaskService,
	execSrvc ExecSrvcFacade,
	submRepo SubmRepo,
	evalRepo EvalRepo,
) *submSrvc

Types

type EvalRepo

type EvalRepo interface {
	GetEval(ctx context.Context, evalUUID uuid.UUID) (domain.Eval, error)
	StoreEval(ctx context.Context, eval domain.Eval) error
}

type ExecSrvcFacade

type ExecSrvcFacade interface {
	Enqueue(ctx context.Context, execUuid uuid.UUID, srcCode string, prLangId string, tests []exec.TestFile, params exec.TestingParams) srvcerror.E
	Listen(ctx context.Context, execUuid uuid.UUID) (<-chan exec.Event, srvcerror.E)
}

type ListSubmsParams

type ListSubmsParams struct {
	Limit  int
	Offset int
	Search string
	Author *uuid.UUID // Optional author UUID to filter by

	IncludeAdmin bool // whether to include admin submissions
}

type ShallowEvalDto

type ShallowEvalDto struct {
	UUID      uuid.UUID
	SubmUUID  uuid.UUID
	Stage     domain.EvalStage
	ScoreUnit domain.ScoreUnit

	Error *domain.EvalError

	// what was used to execute the tests
	Checker    *string
	Interactor *string
	CpuLimMs   int
	MemLimKiB  int

	ScoreInfo *domain.ScoreInfo // precalculated score info, if present

	CreatedAt time.Time
}

shallow submission evaluation data-transfer object. excludes snapshotted subtasks, test groups and tests as those are 1:N relations that are a bit expensive to fetch

includes, however, precalculated score info this object is necessary for listing tasks the user has solved

type ShallowSubmDto

type ShallowSubmDto struct {
	UUID         uuid.UUID
	AuthorUUID   uuid.UUID
	TaskShortID  string
	LangShortID  string
	CurrEvalUUID uuid.UUID
	CreatedAt    time.Time
}

shallow submission (user code for solving task) data-transfer object. excludes the code content itself as that may be up to 100KB in size and there may be many submissions such as for a single user

type ShallowSubmJoinEvalDto

type ShallowSubmJoinEvalDto struct {
	Subm ShallowSubmDto
	Eval ShallowEvalDto
}

shallow submission dto joined with shallow evaluation dto this object is necessary for listing tasks the user has solved

type SubmRepo

type SubmRepo interface {
	AssignEval(ctx context.Context, submUuid uuid.UUID, evalUuid uuid.UUID) error
	GetSubm(ctx context.Context, id uuid.UUID) (domain.Subm, error)
	ListSubms(ctx context.Context, limit int, offset int, search string, authorUuid *uuid.UUID, authorIds []string, taskIds []string, langIds []string, includeAdmin bool) ([]domain.Subm, error)
	// ListSubmsJoinEval(ctx context.Context, authorUuid *uuid.UUID) ([]domain.SubmJoinEval, error)
	StoreSubm(ctx context.Context, subm domain.Subm) error
	CountSubms(ctx context.Context, authorUuid *uuid.UUID, authorIds []string, taskIds []string, langIds []string, includeAdmin bool) (int, error)

	// ListShallowSubmsJoinEval does not return submissions without a corresponding evaluation
	ListShallowSubmsJoinEval(ctx context.Context, authorUuid *uuid.UUID) ([]ShallowSubmJoinEvalDto, error)
}

type SubmissionService

type SubmissionService interface {
	SubmitSol(ctx context.Context, p SubmitSolParams) srvcerror.E
	ReEvalSubm(ctx context.Context, submUuid uuid.UUID) srvcerror.E
	ViewSubm(ctx context.Context, uuid uuid.UUID) (domain.Subm, srvcerror.E)
	ListSubms(ctx context.Context, filter ListSubmsParams) ([]domain.Subm, srvcerror.E)
	GetEval(ctx context.Context, uuid uuid.UUID) (domain.Eval, srvcerror.E)
	SubscribeNewSubms(ctx context.Context) (<-chan domain.Subm, srvcerror.E)
	SubscribeEvalUpds(ctx context.Context) (<-chan domain.Eval, srvcerror.E)
	GetMaxScorePerTask(ctx context.Context, userUUID uuid.UUID) (map[string]domain.MaxScore, srvcerror.E)
	CountSubms(ctx context.Context, search string, author *uuid.UUID, includeAdmin bool) (int, srvcerror.E)
}

SubmissionService is the port (service contract) for it's bounded context

type SubmitSolParams

type SubmitSolParams struct {
	UUID        uuid.UUID
	Submission  string
	ProgrLangID string
	TaskShortID string
	AuthorUUID  uuid.UUID
}

Jump to

Keyboard shortcuts

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