api

package
v0.0.0-...-d8df269 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSlots

func DeleteSlots(name string) error

func DeleteUser

func DeleteUser(name string) error

func GetUserType

func GetUserType(name string) (string, error)

func InsertSlot

func InsertSlot(slot Slot) error

func InsertUser

func InsertUser(user User) error

func IsValidDay

func IsValidDay(day string) error

func IsValidPeriod

func IsValidPeriod(start, end uint) error

func ParseSchedule

func ParseSchedule(c *gin.Context) ([]string, error)

func ScheduleRetrieval

func ScheduleRetrieval(c *gin.Context)

/schedule/ GET

func ScheduleRetrieve

func ScheduleRetrieve(router *gin.RouterGroup)

func SetupRoutes

func SetupRoutes() *gin.Engine

func SlotCreate

func SlotCreate(router *gin.RouterGroup)

func SlotCreation

func SlotCreation(c *gin.Context)

/slots POST

func SlotDelete

func SlotDelete(router *gin.RouterGroup)

func SlotDeletion

func SlotDeletion(c *gin.Context)

/slots/:name DELETE Deletes all slots of a user, could be improved

func SlotRetrieval

func SlotRetrieval(c *gin.Context)

/slots/:name GET

func SlotRetrievalAll

func SlotRetrievalAll(c *gin.Context)

/slots/ GET

func SlotRetrieve

func SlotRetrieve(router *gin.RouterGroup)

func SlotRetrieveAll

func SlotRetrieveAll(router *gin.RouterGroup)

func StartDataBase

func StartDataBase() *gorm.DB

func UpdateUser

func UpdateUser(new User) error

func UserDelete

func UserDelete(router *gin.RouterGroup)

func UserDeletion

func UserDeletion(c *gin.Context)

/user/:name DELETE

func UserModification

func UserModification(c *gin.Context)

/user/ PUT

func UserRegister

func UserRegister(router *gin.RouterGroup)

func UserRegistration

func UserRegistration(c *gin.Context)

/user POST

func UserRetrieval

func UserRetrieval(c *gin.Context)

/user/:name GET

func UserRetrieve

func UserRetrieve(router *gin.RouterGroup)

func UserUpdate

func UserUpdate(router *gin.RouterGroup)

Types

type ScheduleInput

type ScheduleInput struct {
	Candidate    string `json:"candidate" binding:"required"`
	Interviewers string `json:"interviewers" binding:"required"`
}

Main feature Model, scheduling a candidate with one or more interviewers (split by ",")

type Slot

type Slot struct {
	ID         uint   `json:"id" gorm:"primary_key"`
	Name       string `json:"name" binding:"required"`
	WeekNumber uint   `json:"week" binding:"required"`
	Day        string `json:"day" binding:"required"`
	HourStart  uint   `json:"hour_start" binding:"required"`
	HourEnd    uint   `json:"hour_end" binding:"required"`
}

Slot model. WeekNumber as the name implies is the number of the week in a year (1 to 53), leaving the better representation to the front-end.

func GetAllSlots

func GetAllSlots() ([]Slot, error)

func GetSchedule

func GetSchedule(targets []string) ([]Slot, error)

Lists all possible slots between a candidate and one or more interviewers.

func GetSlotUser

func GetSlotUser(name string) ([]Slot, error)

func ParseSlot

func ParseSlot(c *gin.Context) (Slot, error)

Validates and "sanitizes" the Slot Model

func SortSlots

func SortSlots(slots []Slot) []Slot

Sorts slots chronologically, via manual bubblesort

func SplitSlots

func SplitSlots(slot Slot) []Slot

Splits a slot into 1-h slots

type User

type User struct {
	ID   uint   `json:"id" gorm:"primary_key"`
	Name string `json:"name" binding:"required"`
	Mail string `json:"mail" binding:"required"`
	Type string `json:"type" binding:"required"`
}

Simple user model, type is either "candidate" or "interviewer".

func GetUser

func GetUser(name string) (User, error)

Fetches user by username. Could be improved by fetching through primary key, but some conversion mechanism client side would be needed.

func ParseUser

func ParseUser(c *gin.Context) (User, error)

Validates and "sanitizes" the User Model

Jump to

Keyboard shortcuts

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