models

package
v0.0.0-...-adb8fec Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const NumberOfRatings = 7

Variables

Functions

func ConvertToInt64

func ConvertToInt64(number interface{}) int64

ConvertToInt64 ...

func JsonStringToStringUintMap

func JsonStringToStringUintMap(strMap string) (mp map[string]uint)

func JsonStringToUintSlice

func JsonStringToUintSlice(str string) (slice []uint)

func StringUintMapToJsonString

func StringUintMapToJsonString(dict map[string]uint) string

func UintSliceToJsonString

func UintSliceToJsonString(slice []uint) string

Types

type AccessDetails

type AccessDetails struct {
	AccessUUID string
	UserID     uint
}

AccessDetails ...

type AuthModel

type AuthModel struct{}

AuthModel ...

func (AuthModel) CreateAuth

func (m AuthModel) CreateAuth(userID uint, td *TokenDetails) error

CreateAuth ...

func (AuthModel) CreateToken

func (m AuthModel) CreateToken(userID uint) (*TokenDetails, error)

CreateToken ...

func (AuthModel) DeleteAuth

func (m AuthModel) DeleteAuth(givenUUID string) (uint, error)

DeleteAuth ...

func (AuthModel) ExtractToken

func (m AuthModel) ExtractToken(r *http.Request) string

ExtractToken ...

func (AuthModel) ExtractTokenMetadata

func (m AuthModel) ExtractTokenMetadata(r *http.Request) (*AccessDetails, error)

ExtractTokenMetadata ...

func (AuthModel) FetchAuth

func (m AuthModel) FetchAuth(authD *AccessDetails) (uint, error)

FetchAuth ...

func (AuthModel) TokenValid

func (m AuthModel) TokenValid(r *http.Request) error

TokenValid ...

func (AuthModel) VerifyToken

func (m AuthModel) VerifyToken(r *http.Request) (*jwt.Token, error)

VerifyToken ...

type Evaluation

type Evaluation struct {
	gorm.Model
	JudgeID      uint `gorm:"column:judge_id;not null" json:"judge_id"`
	SubmissionID uint `gorm:"column:submission_id;not null" json:"submission_id"`
	// Ratings are integers 1-10 when set
	MainRating             float64 `gorm:"column:main_rating;default:0" json:"main_rating"`
	AnnoyingRating         float64 `gorm:"column:annoying_rating;default:0" json:"annoying_rating"`
	EntertainRating        float64 `gorm:"column:entertaining_rating;default:0" json:"entertaining_rating"`
	BeautifulRating        float64 `gorm:"column:beautiful_rating;default:0" json:"beautiful_rating"`
	SociallyUsefulRating   float64 `gorm:"column:socially_useful_rating;default:0" json:"socially_useful_rating"`
	HardwareRating         float64 `gorm:"column:hardware_rating;default:0" json:"hardware_rating"`
	AwesomelyUselessRating float64 `gorm:"column:awesomely_useless_rating;default:0" json:"awesomely_useless_rating"`
	Normalised             bool    `gorm:"column:normalised;default:false" json:"normalised"`
}

Evaluation ...

func (*Evaluation) ReadRatingsIntoArray

func (e *Evaluation) ReadRatingsIntoArray() []float64

type EvaluationModel

type EvaluationModel struct{}

EvaluationModel ...

func (EvaluationModel) AllForJudge

func (m EvaluationModel) AllForJudge(judgeID uint) (evaluations []Evaluation, err error)

Get all evaluations assigned to a judge

func (EvaluationModel) AllForSubmission

func (m EvaluationModel) AllForSubmission(submissionID uint) (evaluations []Evaluation, err error)

Get all evaluations assigned to a submission

func (EvaluationModel) Create

func (m EvaluationModel) Create(judgeID uint, submissionID uint) (evaluationID uint, err error)

Create ... When this is created, the ratings are not assigned yet and are 0

func (EvaluationModel) CreateStandardised

func (m EvaluationModel) CreateStandardised(judgeID uint, submissionID uint, form forms.EvaluationFormFloat) (evaluationID uint, err error)

CreateStandardised

func (EvaluationModel) Delete

func (m EvaluationModel) Delete(id uint) (err error)

Delete ...

func (EvaluationModel) HaveAllEvaluationsCompleted

func (m EvaluationModel) HaveAllEvaluationsCompleted() (result bool, err error)

func (EvaluationModel) One

func (m EvaluationModel) One(id uint) (evaluation Evaluation, err error)

One ...

func (EvaluationModel) Update

func (m EvaluationModel) Update(id uint, form forms.EvaluationForm) (err error)

Update ...

type Event

type Event string
const (
	TestEvent     Event = "testevent"
	HackNRoll2021 Event = "hacknroll2021"
)

type JSONRaw

type JSONRaw json.RawMessage

JSONRaw ...

func (*JSONRaw) MarshalJSON

func (j *JSONRaw) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*JSONRaw) Scan

func (j *JSONRaw) Scan(src interface{}) error

Scan ...

func (*JSONRaw) UnmarshalJSON

func (j *JSONRaw) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

func (JSONRaw) Value

func (j JSONRaw) Value() (driver.Value, error)

Value ...

type Submission

type Submission struct {
	gorm.Model
	TeamID      uint   `gorm:"column:team_id;not null" json:"-"`
	ProjectName string `gorm:"column:project_name" json:"project_name"`
	Description string `gorm:"column:description" json:"description"`
	Images      string `gorm:"column:images" json:"images"` // comma separated list of image ids
	Team        Team   `gorm:"column:team" json:"team"`
	Likes       int    `gorm:"column:likes" json:"likes"`
}

Submission ...

type SubmissionLike

type SubmissionLike struct {
	gorm.Model
	UserID       uint `gorm:"column:user_id;not null" json:"-"`
	SubmissionID uint `gorm:"column:submission_id;not null" json:"-"`
}

Submission ...

type SubmissionLikeModel

type SubmissionLikeModel struct{}

SubmissionModel ...

func (SubmissionLikeModel) AllForUserID

func (m SubmissionLikeModel) AllForUserID(userID uint) (submissionLikes []SubmissionLike, err error)

All ...

func (SubmissionLikeModel) Create

func (m SubmissionLikeModel) Create(submissionID uint, userID uint) (likeID uint, err error)

Create ...

func (SubmissionLikeModel) Delete

func (m SubmissionLikeModel) Delete(submissionID uint, userID uint) (err error)

Delete ...

func (SubmissionLikeModel) One

func (m SubmissionLikeModel) One(submissionID uint, userID uint) (submissionLike SubmissionLike, err error)

One ...

type SubmissionModel

type SubmissionModel struct{}

SubmissionModel ...

func (SubmissionModel) AllForEvent

func (m SubmissionModel) AllForEvent(event Event) (submissions []Submission, err error)

func (SubmissionModel) AllForUserID

func (m SubmissionModel) AllForUserID(userID uint) (submissions []Submission, err error)

All ...

func (SubmissionModel) Create

func (m SubmissionModel) Create(teamID uint, form forms.SubmissionForm) (submissionID uint, err error)

Create ...

func (SubmissionModel) Delete

func (m SubmissionModel) Delete(teamID uint) (err error)

Delete ...

func (SubmissionModel) IncrementLike

func (m SubmissionModel) IncrementLike(submissionID uint, increment int) (err error)

func (SubmissionModel) One

func (m SubmissionModel) One(submissionID uint) (submission Submission, err error)

One ...

func (SubmissionModel) OneByTeamID

func (m SubmissionModel) OneByTeamID(teamID uint) (submission Submission, err error)

One ...

func (SubmissionModel) Update

func (m SubmissionModel) Update(teamID uint, form forms.SubmissionForm) (err error)

Update ...

type SubmissionRanking

type SubmissionRanking struct {
	gorm.Model
	SubmissionID uint `gorm:"column:submission_id;not null" json:"submission_id"`
	// Rankings are position from 1 to num_submissions
	MainRanking             uint `gorm:"column:main_ranking;default:0" json:"main_ranking"`
	AnnoyingRanking         uint `gorm:"column:annoying_ranking;default:0" json:"annoying_ranking"`
	EntertainRanking        uint `gorm:"column:entertaining_ranking;default:0" json:"entertaining_ranking"`
	BeautifulRanking        uint `gorm:"column:beautiful_ranking;default:0" json:"beautiful_ranking"`
	SociallyUsefulRanking   uint `gorm:"column:socially_useful_ranking;default:0" json:"socially_useful_ranking"`
	HardwareRanking         uint `gorm:"column:hardware_ranking;default:0" json:"hardware_ranking"`
	AwesomelyUselessRanking uint `gorm:"column:awesomely_useless_ranking;default:0" json:"awesomely_useless_ranking"`

	MainScore             float64 `gorm:"column:main_score;default:0" json:"main_score"`
	AnnoyingScore         float64 `gorm:"column:annoying_score;default:0" json:"annoying_score"`
	EntertainScore        float64 `gorm:"column:entertaining_score;default:0" json:"entertaining_score"`
	BeautifulScore        float64 `gorm:"column:beautiful_score;default:0" json:"beautiful_score"`
	SociallyUsefulScore   float64 `gorm:"column:socially_useful_score;default:0" json:"socially_useful_score"`
	HardwareScore         float64 `gorm:"column:hardware_score;default:0" json:"hardware_score"`
	AwesomelyUselessScore float64 `gorm:"column:awesomely_useless_score;default:0" json:"awesomely_useless_score"`
}

type SubmissionRankingModel

type SubmissionRankingModel struct{}

func (SubmissionRankingModel) All

func (m SubmissionRankingModel) All() (submissionRankings []SubmissionRanking, err error)

All ...

func (SubmissionRankingModel) AllByCategory

func (m SubmissionRankingModel) AllByCategory(category string) (submissionRankings []SubmissionRanking, err error)

Sorted by category score descending order

func (SubmissionRankingModel) Create

func (m SubmissionRankingModel) Create(
	submissionID uint, scoresArray []float64) (submissionRankingID uint, err error)

Create ... When this is created, the rankings are not assigned yet and are 0

func (SubmissionRankingModel) DeleteBySubmissionID

func (m SubmissionRankingModel) DeleteBySubmissionID(submissionID uint) (err error)

Delete ...

func (SubmissionRankingModel) OneBySubmissionID

func (m SubmissionRankingModel) OneBySubmissionID(submissionID uint) (submissionRanking SubmissionRanking, err error)

One ...

func (SubmissionRankingModel) Update

func (m SubmissionRankingModel) Update(submissionID uint, form map[string]uint) (err error)

Update ...

type Team

type Team struct {
	gorm.Model
	TeamName            string `gorm:"column:team_name;not_null" json:"team_name"`
	Event               Event  `gorm:"column:event;not_null" json:"event"`
	UserIDs             string `gorm:"column:user_ids;not_null" json:"user_ids"`
	IsFreshmanTeam      bool   `gorm:"column:is_freshman_team;default:false" json:"is_freshman_team"`
	IsPreUniversityTeam bool   `gorm:"column:is_pre_university_team;default:false" json:"is_pre_university_team"`
	IsBeginnerTeam      bool   `gorm:"column:is_beginner_team;default:false" json:"is_beginner_team"`
}

Team

type TeamInvite

type TeamInvite struct {
	gorm.Model
	TeamID uint `gorm:"column:team_id;not null" json:"team_id"`
	UserID uint `gorm:"column:user_id;not null" json:"user_id"`
}

TeamInvite ...

type TeamInviteModel

type TeamInviteModel struct{}

TeamInviteModel ...

func (TeamInviteModel) All

func (m TeamInviteModel) All(userID uint) (teamInvites []TeamInvite, err error)

All ...

func (TeamInviteModel) Create

func (m TeamInviteModel) Create(userID uint, teamID uint) (teamInviteID uint, err error)

Create ...

func (TeamInviteModel) Delete

func (m TeamInviteModel) Delete(userID, teamID uint) (err error)

Delete ...

func (TeamInviteModel) One

func (m TeamInviteModel) One(userID, teamID uint) (teamInvite TeamInvite, err error)

One ...

type TeamModel

type TeamModel struct{}

TeamModel

func (TeamModel) AddTeamMember

func (m TeamModel) AddTeamMember(userID uint, teamID uint) (err error)

func (TeamModel) All

func (m TeamModel) All(userID uint) (teams []Team, err error)

All ...

func (TeamModel) Create

func (m TeamModel) Create(userID uint, form forms.TeamForm, event Event) (TeamID uint, err error)

Create ...

func (TeamModel) Delete

func (m TeamModel) Delete(teamID uint) (err error)

Delete ... Note this does not delete the team's submission

func (TeamModel) One

func (m TeamModel) One(teamID uint) (team Team, err error)

One ...

func (TeamModel) RemoveTeamMember

func (m TeamModel) RemoveTeamMember(userID uint, teamID uint) (err error)

func (TeamModel) Update

func (m TeamModel) Update(teamID uint, form forms.TeamForm) (err error)

Update ...

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

Token ...

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	AccessUUID   string
	RefreshUUID  string
	AtExpires    int64
	RtExpires    int64
}

TokenDetails ...

type User

type User struct {
	gorm.Model
	Email          string   `gorm:"column:email;not null;unique" json:"email"`
	Password       string   `gorm:"column:password" json:"-"`
	Name           string   `gorm:"column:name" json:"name"`
	UserType       UserType `gorm:"column:user_type;default:0" json:"user_type"`
	TeamIDForEvent string   `gorm:"column:team_id_for_event;default:'{}'" json:"team_id_for_event"`
}

Team ...

type UserModel

type UserModel struct{}

UserModel ...

func (UserModel) GetAllJudges

func (m UserModel) GetAllJudges() (judges []User, err error)

func (UserModel) GetTeamIDForEventMap

func (m UserModel) GetTeamIDForEventMap(user User) map[string]uint

func (UserModel) GetUserByEmail

func (m UserModel) GetUserByEmail(email string) (user User, err error)

func (UserModel) IsJudgeForUserID

func (m UserModel) IsJudgeForUserID(id uint) (bool, error)

func (UserModel) Login

func (m UserModel) Login(form forms.LoginForm) (user User, token Token, err error)

Login ...

func (UserModel) One

func (m UserModel) One(userID uint) (user User, err error)

One ...

func (UserModel) Register

func (m UserModel) Register(form forms.RegisterForm) (user User, err error)

Register ...

func (UserModel) UpdateTeamForUser

func (m UserModel) UpdateTeamForUser(userID, teamID uint, event Event) (err error)

type UserSessionInfo

type UserSessionInfo struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

UserSessionInfo ...

type UserType

type UserType int
const (
	Participant UserType = iota // 0
	Judge                       // 2
	Admin                       // 3
)

Jump to

Keyboard shortcuts

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