catalog

package
v0.0.0-...-52ed2a8 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTermID

func GetTermID(term string) int

GetTermID will return the term id given the term name

Types

type BlueprintParams

type BlueprintParams struct {
	PageParams
	SemesterParams
	Units int `query:"units" form:"units"`
}

BlueprintParams is the set of parameters for the blueprint query.

type Catalog

type Catalog []*Course

Catalog is the course catalog

type Course

type Course struct {
	Entry
	Exam       Exam          `db:"exam" json:"exam"`
	Subcourses SubCourseList `db:"subcourses" json:"subcourses"`
}

Course is a course

type CourseBlueprint

type CourseBlueprint struct {
	Subject   string        `db:"subject" json:"subject"`
	CourseNum int           `db:"course_num" json:"course_num"`
	Title     string        `db:"title" json:"title"`
	MinUnits  int           `db:"min_units" json:"min_units"`
	MaxUnits  int           `db:"max_units" json:"max_units"`
	Enrolled  int           `db:"enrolled" json:"enrolled"`
	Capacity  int           `db:"capacity" json:"capacity"`
	Percent   float64       `db:"percent" json:"percent"`
	CRNs      pq.Int32Array `db:"crns" json:"crns"`
	IDs       pq.Int32Array `db:"ids" json:"ids"`
	Count     int           `db:"count" json:"count"`
}

CourseBlueprint is an overview of all of the instances of one course. It tells what the course subject and number are and contains a list of IDs that point to spesific instances of the course.

func GetBlueprints

func GetBlueprints(params *BlueprintParams) ([]*CourseBlueprint, error)

GetBlueprints will

type Entry

type Entry struct {
	ID          int       `db:"id" json:"id" csv:"-"`
	CRN         int       `db:"crn" json:"crn"`
	Subject     string    `db:"subject" json:"subject"`
	CourseNum   int       `db:"course_num" json:"course_num"`
	Type        string    `db:"type" json:"type"`
	Title       string    `db:"title" json:"title"`
	Units       int       `db:"units" json:"units" csv:"units"`
	Days        Weekdays  `db:"days" json:"days" csv:"days" goqu:"skipinsert"`
	Description string    `db:"description" json:"description"`
	Capacity    int       `db:"capacity" json:"capacity"`
	Enrolled    int       `db:"enrolled" json:"enrolled"`
	Remaining   int       `db:"remaining" json:"remaining"`
	UpdatedAt   time.Time `db:"updated_at" json:"updated_at" csv:"-" goqu:"skipupdate,skipinsert"`
	Year        int       `db:"year" json:"year" csv:"year"`
	TermID      int       `db:"term_id" json:"term_id" csv:"term_id"`
}

Entry is an entry in the catalog

type Exam

type Exam struct {
	Date      time.Time `db:"date" json:"date"`
	StartTime time.Time `db:"start_time" json:"start_time"`
	EndTime   time.Time `db:"end_time" json:"end_time"`
}

Exam is an exam

func (*Exam) Scan

func (e *Exam) Scan(v interface{}) error

Scan implements the database/sql scan interface

type PageParams

type PageParams struct {
	Limit  *uint `form:"limit"  query:"limit"  db:"limit"`
	Offset *uint `form:"offset" query:"offset" db:"offset"`
}

PageParams are url params for api pagination

func (*PageParams) AppendSelect

func (pp *PageParams) AppendSelect(stmt *goqu.SelectDataset) *goqu.SelectDataset

AppendSelect appends the parameters to a generated sql query statement

func (*PageParams) Clone

func (pp *PageParams) Clone() goqu.Expression

Clone implements the goqu.Expression interface

func (*PageParams) Expression

func (pp *PageParams) Expression() goqu.Expression

Expression implements the goqu.Expression interface

type SemesterParams

type SemesterParams struct {
	Year    int    `form:"year" uri:"year" query:"year" db:"year"`
	Term    string `form:"term" uri:"term" query:"term" db:"term_id"`
	Subject string `form:"subject" query:"subject" db:"subject"`
}

SemesterParams is a structure that defines parameters that control which courses are returned from a query

func (*SemesterParams) Bind

func (sp *SemesterParams) Bind(c *gin.Context) (err error)

Bind will bind a request to the params

func (*SemesterParams) Clone

func (sp *SemesterParams) Clone() goqu.Expression

Clone implements the goqu.Expression interface

func (*SemesterParams) Expression

func (sp *SemesterParams) Expression() goqu.Expression

Expression implements the goqu.Expression interface

type SubCourse

type SubCourse struct {
	CRN          int       `db:"crn" json:"crn"`
	CourseCRN    int       `db:"course_crn" json:"course_crn"`
	Section      string    `db:"section" json:"section"`
	StartTime    time.Time `db:"start_time" json:"start_time,omitempty"`
	EndTime      time.Time `db:"end_time" json:"end_time,omitempty"`
	Building     string    `db:"building_room" json:"building_room"`
	InstructorID int64     `db:"instructor_id" json:"instructor_id"`
	UpdatedAt    time.Time `db:"updated_at" json:"updated_at" csv:"-" goqu:"skipupdate,skipinsert"`
	Enrolled     int       `db:"enrolled" json:"enrolled"`
	Capacity     int       `db:"capacity" json:"capacity"`
	Remaining    int       `db:"remaining" json:"remaining"`
	Days         Weekdays  `db:"days" json:"days"`
}

SubCourse is an auxillary course that is meant to be taken along side some other main course

type SubCourseList

type SubCourseList []SubCourse

SubCourseList is a list of SubCourses that maintains interoperability with postgresql json blobs.

func (*SubCourseList) Scan

func (sc *SubCourseList) Scan(val interface{}) error

Scan will convert the list of subcourses from json to a serialized struct slice.

type Weekday

type Weekday string

Weekday is a weekday

const (
	Sunday    Weekday = "sunday"
	Monday    Weekday = "monday"
	Tuesday   Weekday = "tuesday"
	Wednesday Weekday = "wednesday"
	Thursday  Weekday = "thursday"
	Friday    Weekday = "friday"
	Saturday  Weekday = "saturday"
)

These are all weekday values

func NewWeekdays

func NewWeekdays(days []time.Weekday) []Weekday

NewWeekdays will convert a slice of time.Weekday to []catalog.Weekday

func WeekdayFromTimePkg

func WeekdayFromTimePkg(w time.Weekday) Weekday

WeekdayFromTimePkg will create a new Weekday from a time.Weekdays

func (*Weekday) Scan

func (w *Weekday) Scan(val interface{}) error

Scan is populate the weekday's value from the results of a database query

type Weekdays

type Weekdays []Weekday

Weekdays is a slice of weekdays

func (*Weekdays) Scan

func (wk *Weekdays) Scan(val interface{}) error

Scan is used when querying the database for weekdays strings

Jump to

Keyboard shortcuts

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