compiler

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(rc models.RemoteCompiler)

func GetBestSubmissionHandler

func GetBestSubmissionHandler(w http.ResponseWriter, r *http.Request)

GetBestSubmissionHandler will check if a user is logged in, then grab their best submission using a short submission. If no submission is found, a 204 is returned to the user

func GetSubmission

func GetSubmission(w http.ResponseWriter, r *http.Request)

GetSubmission gets a single submission if the users BGID is the same as the submission requested

func LeaderboardHandler

func LeaderboardHandler(w http.ResponseWriter, r *http.Request)

Possible query strings:

"hole": ID of the hole *REQUIRED*
"limit": Limit of entry numbers. Max of 10. Defaults to 10.
"lang": Specific language to query for. Defaults to all languages.

func ListSubmissions

func ListSubmissions(w http.ResponseWriter, r *http.Request)

ListSubmissions needs to be able to list submissions for ONLY the logged in user. It lists submissions in a short submission fasion, without sending the entire script back.

Possible query strings:

"hole": Optional query string just to get submissions for a single hole

Types

type Entry

type Entry struct {
	ID       string
	Language string
	Version  string
	Length   int64
	HoleID   string
	BGID     string

	// Following fields get populated by the BGID on a request basis
	GitName string
}

func LeaderboardQuery

func LeaderboardQuery(query firestore.Query, limit int) ([]Entry, error)

LeaderboardQuery is a wrapper query function to list leaderboard submissions for a given hole. Since leaderboard have to be unique by BGID, that query is handled in this function. If the limit is not reached it will return a slice of the users it was able to get

func (*Entry) GetUserFields

func (e *Entry) GetUserFields() error

GetUserFields populates the user fields based on BGID

type FullSubmission

type FullSubmission struct {
	ShortSubmission

	Script string
	Tests  map[string]SubmissionTest
}

FullSubmission extends the ShortSubmission with the Script and TestCases

type ShortSubmission

type ShortSubmission struct {
	ID            string
	Language      string
	Version       string
	BGID          string
	HoleID        string
	Length        int64
	SubmittedTime time.Time
	Correct       bool
	HoleName      string
}

ShortSubmission is the short submission for the frontend to list all submissions, correct or incorrect without the entire script

type SubmissionDB

type SubmissionDB struct {
	ID       string
	Script   string
	Language string
	Version  string
	Correct  bool
	BGID     string
	HoleID   string
	Length   int64

	// Timestamps
	SubmittedTime time.Time

	// Tests holds data for each individual test and whether it was correct or not
	Tests     SubmissionTests
	TestCount int
}

SubmissionDB is complete submission object that gets stored in the database

func BestSubmission

func BestSubmission(bgid, hole string) (*SubmissionDB, error)

BestSubmission takes a bgid and hole and returns the user's best submission for that given hole

func NewSubmissionDB

func NewSubmissionDB(holeID, bgID, script, language, version string) *SubmissionDB

func SubmissionsQuery

func SubmissionsQuery(query firestore.Query) ([]SubmissionDB, error)

SubmissionsQuery is a query wrapper to add results to a cache for when a GET is called at a later time TODO: add a cache

func (*SubmissionDB) AddTest

func (sub *SubmissionDB) AddTest(testID, output string, correct, hidden bool)

func (SubmissionDB) Collection

func (sub SubmissionDB) Collection() *firestore.CollectionRef

Store interface functions

func (SubmissionDB) Data

func (sub SubmissionDB) Data() interface{}

func (SubmissionDB) DocID

func (sub SubmissionDB) DocID() string

func (SubmissionDB) Entry

func (sub SubmissionDB) Entry() Entry

func (*SubmissionDB) FullSub

func (sub *SubmissionDB) FullSub() (*FullSubmission, error)

func (*SubmissionDB) ShortSub

func (sub *SubmissionDB) ShortSub(holename bool) (*ShortSubmission, error)

ShortSub turns a SubmissionDB to a ShortSubmission. If holename is set to true, the database is hit and the hole name is grabbed, otherwise the error check is not needed and the HoleName will be set to ""

type SubmissionTest

type SubmissionTest struct {
	Correct bool   // Test correct or not
	Hidden  bool   // Whether to show the output on the frontend or not
	Output  string `json:"Output,omitempty"` // User test output
}

SubmissionTest is the test output that gets stored in the Tests field under SubmissionDB

type SubmissionTests

type SubmissionTests map[string]SubmissionTest

func (SubmissionTests) HideHidden

func (st SubmissionTests) HideHidden() SubmissionTests

HideHidden hides the hidden test cases after getting the entire object from the database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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