Documentation ¶
Index ¶
- func CompleteSignup(DB db.Database, userHash, collection, email, password string) error
- type Comment
- type CommentRating
- type CommentReport
- type Course
- type Institute
- type Major
- type Offering
- type OfferingStats
- type Professor
- type Record
- type Requirement
- type Stats
- type StatsEntry
- type Subject
- type SubjectReview
- type User
- type UserComment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Comment ¶
type Comment struct { ID uuid.UUID `firestore:"id"` Rating int `firestore:"rating"` Body string `firestore:"body"` Edited bool `firestore:"edited"` Timestamp time.Time `firestore:"last_update"` Upvotes int `firestore:"upvotes"` Downvotes int `firestore:"downvotes"` Reports int `firestore:"reports"` Verified bool `firestore:"verified,omitempty"` User string `firestore:"-"` // not stored just used for hashing }
Comment is the DTO for a comment
type CommentRating ¶
type CommentRating struct { ID uuid.UUID `firestore:"id"` Upvote bool `firestore:"upvote"` ProfessorHash string `firestore:"professor"` Subject string `firestore:"subject"` Course string `firestore:"course"` Specialization string `firestore:"specialization"` }
CommentRating is the DTO for a comment rating, it contains offering data and the rating evaluation
func (CommentRating) Hash ¶
func (cr CommentRating) Hash() string
Hash returns the ID associated to the rated comment
type CommentReport ¶
type CommentReport struct { ID uuid.UUID `firestore:"id"` Report string `firestore:"report"` ProfessorHash string `firestore:"professor"` Subject string `firestore:"subject"` Course string `firestore:"course"` Specialization string `firestore:"specialization"` }
CommentReport is the DTO for a comment report, it contains offering data and the report
func (CommentReport) Hash ¶
func (cr CommentReport) Hash() string
Hash returns the UUID associated to the reported comment
type Course ¶
type Course struct { Name string `firestore:"name"` Code string `firestore:"code"` Specialization string `firestore:"specialization"` Shift string `firestore:"shift"` SubjectCodes map[string]string `firestore:"subjects"` Subjects []Subject `firestore:"-"` // institute code, just used for querying, TODO: actually collect this in the scraper Institute string `firestore:"-"` }
Course is the DTO for a course Example: {"Bacharelado em Ciências de Computação", "55041", []Subjects{...}, map[string]string{"SMA0356": "Cálculo IV", ...}}
func NewCourseFromController ¶
func NewCourseFromController(course *controllers.InstituteCourse) *Course
NewCourseFromController is a constructor. It takes a course controller and returns a model.
type Institute ¶
type Institute struct { Name string `firestore:"name"` Code string `firestore:"code"` // Attributes only used to nest collected data by uspy-scraper Courses []Course `firestore:"-"` Professors []Professor `firestore:"-"` }
Institute represents an institute or collection of courses
func NewInstituteFromController ¶
func NewInstituteFromController(controller *controllers.Institute) *Institute
NewInstituteFromController is a constructor. It takes a institute controller and returns a model.
type Major ¶
type Major struct { Code string `firestore:"course"` Specialization string `firestore:"specialization"` }
Major is the DTO for a course/major. It represents a tuple (course, specialization)
It is used for storing which courses a user has records of
func NewMajorFromController ¶
func NewMajorFromController(major *controllers.Major) *Major
NewMajorFromController is a constructor. It takes a major controller and returns a model.
type Offering ¶
type Offering struct { CodPes string `firestore:"-"` Code string `firestore:"-"` Professor string `firestore:"professor"` Years []string `firestore:"years"` }
Offering is the DTO for an offering of a subject Since it is inside a subcollection of a subject, it does not have subject data
It contains some properties that are not mapped to firestore for internal logic and data collection purposes.
type OfferingStats ¶
OfferingStats represents the evaluation stats for an offering.
It is not a DTO and is only used in internal logic.
type Professor ¶
type Professor struct { CodPes string `firestore:"-"` CodPesHash string `firestore:"-"` // used only when the ID is unknown Name string `firestore:"name"` Offerings []Offering `firestore:"-"` }
Professor is an object that represents a USP professor
It is not a DTO and is only used for data collection purposes
type Record ¶
type Record struct { Subject string `firestore:"-"` Course string `firestore:"-"` Specialization string `firestore:"-"` Year int `firestore:"-"` Semester int `firestore:"-"` Grade float64 `firestore:"grade"` Status string `firestore:"status,omitempty"` Frequency int `firestore:"frequency,omitempty"` }
Record is a DTO for a user's subject grade record
It contains some properties that are not mapped to the database and solely used for internal, contextual logic.
func (Record) Hash ¶
Hash returns SHA256(concat(record_year, record_semester))
This is done in this way so that if a user has more than one record for a given subject, they differ by when the subject was taken.
type Requirement ¶
type Requirement struct { Subject string `firestore:"code"` Name string `firestore:"name"` Strong bool `firestore:"strong"` }
Requirement represents a subject requirement
It is nested inside a subject DTO and not mapped directly to a document
type Stats ¶ added in v1.5.2
type Stats struct { Users StatsEntry `firestore:"users"` Grades StatsEntry `firestore:"grades"` Subjects StatsEntry `firestore:"subjects"` Offerings StatsEntry `firestore:"offerings"` Comments StatsEntry `firestore:"comments"` }
Stats is a DTO for the database stats
type StatsEntry ¶ added in v1.5.2
type StatsEntry struct { Name string `firestore:"name"` Count int `firestore:"count"` LastUpdate time.Time `firestore:"last_update"` }
StatsEntry represents a simple counter
type Subject ¶
type Subject struct { Code string `firestore:"code"` CourseCode string `firestore:"course"` Specialization string `firestore:"specialization"` Name string `firestore:"name"` Description string `firestore:"desc"` Semester int `firestore:"semester"` ClassCredits int `firestore:"class"` AssignCredits int `firestore:"assign"` TotalHours string `firestore:"hours"` Requirements map[string][]Requirement `firestore:"requirements"` TrueRequirements []Requirement `firestore:"true_requirements"` Optional bool `firestore:"optional"` Stats map[string]int `firestore:"stats"` }
Subject is the DTO for a subject.
It is probably one of the most used objects.
func NewSubjectFromController ¶
func NewSubjectFromController(sub *controllers.Subject) *Subject
NewSubjectFromController is a constructor. It takes a subject controller and returns a model.
type SubjectReview ¶
type SubjectReview struct { Subject string `firestore:"-"` Course string `firestore:"-"` Specialization string `firestore:"-"` Review map[string]interface{} `firestore:"categories"` }
SubjectReview is the DTO for a subject review/evaluation made by an user
func NewSubjectReviewFromController ¶
func NewSubjectReviewFromController(controller *controllers.SubjectReview) *SubjectReview
NewSubjectReviewFromController is a constructor. It takes a controller and returns a model.
func (SubjectReview) Hash ¶
func (sr SubjectReview) Hash() string
Hash returns SHA256(concat(subject, course, specialization))
type User ¶
type User struct { ID string `firestore:"-"` IDHash string `firestore:"-"` // used only when the ID is unknown Name string `firestore:"-"` // NameHash is AES encrypted since it has to be decrypted NameHash string `firestore:"name"` // EmailHash is SHA256 encrypted because it must be queried in signup EmailHash string `firestore:"email"` Verified bool `firestore:"verified"` // Email verification Banned bool `firestore:"banned"` // bcrypt hashing cause password is more sensitive PasswordHash string `firestore:"password"` LastUpdate time.Time `firestore:"last_update"` TranscriptYears map[string][]int `firestore:"transcript_years"` // map of years as keys and array of semesters as values }
User is the DTO for a registered user
It also contains non mapped properties used for internal contextual logic.
func NewUser ¶
func NewUser(ID, name string, lastUpdate time.Time, transcriptYears map[string][]int) (*User, error)
NewUser creates a new user. It takes raw data and processes all the encrypted data
User email verification is also bypassed in dev or local environments
type UserComment ¶
type UserComment struct { Comment `firestore:"comment"` ProfessorHash string `firestore:"professor"` Subject string `firestore:"subject"` Course string `firestore:"course"` Specialization string `firestore:"specialization"` }
UserComment is the DTO for a user comment
It is a replica of the comment object, but stored in the context of the user instead of the offering
func (UserComment) Hash ¶
func (uc UserComment) Hash() string
Hash returns SHA256(concat(subject, course, specialization, professor_hash))
Note here that professor_hash is a hex sha256 value and not their numeric id.