submission

package
v0.0.0-...-9f3f5e4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSubmission = errors.New("mongo: no submission in result")

Functions

func Init

func Init(sm *http.ServeMux, l *log.Logger, mongo *db.Mongo)

Types

type Controller

type Controller struct {
	Logger     *log.Logger
	Repository *Repository
	// contains filtered or unexported fields
}

func (*Controller) Create

func (*Controller) Get

func (h *Controller) Get(submissionNumber int) (utl.StatusCode, *utl.ResponseBody)

func (*Controller) Gets

func (h *Controller) Gets() (utl.StatusCode, *utl.ResponseBody)

type CreateSubmission

type CreateSubmission struct {
	ProblemNumber int    `json:"problem_number"`
	Language      string `json:"language"`
	Code          string `json:"code"`
}

func (*CreateSubmission) ToSubmission

func (cs *CreateSubmission) ToSubmission() *Submission

type ExecutedTestCase

type ExecutedTestCase struct {
	Input  string `bson:"input" json:"input"`
	Answer string `bson:"answer" json:"answer"`
	Output string `bson:"output" json:"output"`
}

type Handler

type Handler struct {
	Logger     *log.Logger
	Repository *Repository
	Controller *Controller
}

func (*Handler) Decide

func (*Handler) GetHandler

func (*Handler) PostHandler

func (h *Handler) PostHandler(w http.ResponseWriter, r *http.Request) (utl.StatusCode, *utl.ResponseBody)

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type M

type M map[string]interface{}

type Repository

type Repository struct {
	Logger     *log.Logger
	Collection *mongo.Collection
}

func (*Repository) Find

func (r *Repository) Find() ([]Submission, error)

func (*Repository) FindByID

func (r *Repository) FindByID(id *primitive.ObjectID) (*Submission, error)

func (*Repository) FindBySubmissionNumber

func (r *Repository) FindBySubmissionNumber(submissionNumber int) (*Submission, error)

func (*Repository) Save

func (*Repository) Update

func (r *Repository) Update(s *Submission) (*Submission, error)

type Submission

type Submission struct {
	ID                primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
	SubmittedUsername string             `bson:"submitted_username" json:"submitted_username"`
	ProblemNumber     int                `bson:"problem_number" json:"problem_number"`
	SubmissionNumber  int                `bson:"submission_number" json:"submission_number"`
	Status            string             `bson:"status" json:"status"`
	Language          string             `bson:"language" json:"language"`
	Code              string             `bson:"code" json:"code"`
	Runtime           int                `bson:"runtime" json:"runtime"`
	Memory            int                `bson:"memory" json:"memory"`
	ExecutedTestCases []ExecutedTestCase `bson:"executed_test_cases" json:"executed_test_cases"`
	CreatedAt         time.Time          `bson:"created_at" json:"created_at"`
	UpdatedAt         time.Time          `bson:"updated_at" json:"updated_at"`
}

Jump to

Keyboard shortcuts

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