crawler

package module
v0.0.0-...-dc32160 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DBHost     = os.Getenv("ITUSCHEDULER_POSTGRES_HOST")
	DBName     = os.Getenv("ITUSCHEDULER_POSTGRES_NAME")
	DBUser     = os.Getenv("ITUSCHEDULER_POSTGRES_USER")
	DBPassword = os.Getenv("ITUSCHEDULER_POSTGRES_PASSWORD")
	DBPort     = os.Getenv("ITUSCHEDULER_POSTGRES_PORT")
	DBSSLMode  = os.Getenv("ITUSCHEDULER_POSTGRES_SSLMODE")
	DB         *gorm.DB
	//go:embed templates/*
	Templates embed.FS
)

Functions

func AutoMigrateDB

func AutoMigrateDB()

func GetRefreshCourses

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

func GetRefreshMajors

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

func InitDB

func InitDB()

func PostRefreshCourses

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

func PostRefreshMajors

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

func ScrapeCoursesOfMajors

func ScrapeCoursesOfMajors(majors []Major)

func ScrapeMajors

func ScrapeMajors()

Types

type Course

type Course struct {
	CRN              string `gorm:"primarykey"`
	MajorCode        string `gorm:"not null"`
	Major            Major  `gorm:"foreignKey:MajorCode;constraint:OnDelete:CASCADE"`
	Code             string
	Catalogue        string
	Title            string
	TeachingMethod   string
	Instructor       string
	Lectures         []Lecture
	Capacity         int
	Enrolled         int
	Reservation      string
	MajorRestriction string
	Prerequisites    string
	ClassRestriction string
	CreatedAt        time.Time
	UpdatedAt        time.Time
	DeletedAt        gorm.DeletedAt `gorm:"index"`
}

type Lecture

type Lecture struct {
	gorm.Model
	CourseCRN string `gorm:"uniqueIndex:idx_lecture;not null"`
	Course    Course `gorm:"foreignKey:CourseCRN;constraint:OnDelete:CASCADE"`
	Building  string
	Day       string `gorm:"uniqueIndex:idx_lecture"`
	Time      string `gorm:"uniqueIndex:idx_lecture"`
	TimeStart int
	TimeEnd   int
	Room      string
}

type Major

type Major struct {
	Code        string `gorm:"primarykey"`
	Courses     []Course
	CreatedAt   time.Time
	RefreshedAt time.Time
}

type Post

type Post struct {
	gorm.Model
	Author  string        `json:"author"`
	Date    string        `json:"date"`
	Content template.HTML `json:"content"`
}

type Result

type Result struct {
	Major    Major
	Courses  []Course
	Lectures []Lecture
}

type Schedule

type Schedule struct {
	gorm.Model
	UserID     uint `gorm:"not null"`
	User       User `gorm:"constraint:OnDelete:CASCADE;"`
	IsSelected bool
	Courses    []Course `gorm:"many2many:schedule_courses_go;"`
}

func (Schedule) TableName

func (Schedule) TableName() string

type Session

type Session struct {
	Token     string `gorm:"primarykey"`
	UserID    uint   `gorm:"not null"`
	User      User   `gorm:"constraint:OnDelete:CASCADE"`
	ExpiresAt time.Time
	CreatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type User

type User struct {
	gorm.Model
	Username   string  `gorm:"unique" validate:"required"`
	Email      *string `gorm:"unique" validate:"required,email"`
	Password   *string `validate:"required"`
	IsAdmin    bool
	FacebookID *string `gorm:"unique"`
	TwitterID  *string `gorm:"unique"`
	MajorCode  *string
	Major      Major    `gorm:"foreignKey:MajorCode"`
	Courses    []Course `gorm:"many2many:user_courses_go;"`
	Schedules  []Schedule
	Sessions   []Session
}

Jump to

Keyboard shortcuts

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