decided to add season support
This commit is contained in:
@@ -27,6 +27,16 @@ export enum Status {
|
||||
CANCELLED = 'CANCELLED',
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a semester, with the year and the season for when a course is offered
|
||||
*/
|
||||
export type Semester = {
|
||||
/** The year that the semester is in */
|
||||
year: number;
|
||||
/** The season that the semester is in (Fall, Spring, Summer) */
|
||||
season: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The internal representation of a course for the extension
|
||||
*/
|
||||
@@ -59,6 +69,8 @@ export class Course {
|
||||
flags: string[];
|
||||
/** How is the class being taught (online, hybrid, in person, etc) */
|
||||
instructionMode: InstructionMode;
|
||||
/** Which semester is the course from */
|
||||
semester: Semester;
|
||||
|
||||
constructor(course: Course | Serialized<Course>) {
|
||||
Object.assign(this, course);
|
||||
|
||||
@@ -60,8 +60,18 @@ export class CourseScraper {
|
||||
fullName = fullName.replace(/\s\s+/g, ' ').trim();
|
||||
|
||||
const [courseName, department, number] = this.separateCourseName(fullName);
|
||||
|
||||
const [status, isReserved] = this.getStatus(row);
|
||||
|
||||
// TODO: get semester from somewhere
|
||||
const year = new Date().getFullYear();
|
||||
const month = new Date().getMonth();
|
||||
let season = 'Fall';
|
||||
if (month >= 0 && month < 5) {
|
||||
season = 'Spring';
|
||||
} else if (month >= 5 && month < 8) {
|
||||
season = 'Summer';
|
||||
}
|
||||
|
||||
const newCourse = new Course({
|
||||
fullName,
|
||||
courseName,
|
||||
@@ -77,6 +87,11 @@ export class CourseScraper {
|
||||
instructionMode: this.getInstructionMode(row),
|
||||
instructors: this.getInstructors(row),
|
||||
description: this.getDescription(document),
|
||||
// TODO: get semester from somewhere
|
||||
semester: {
|
||||
year,
|
||||
season,
|
||||
},
|
||||
});
|
||||
courses.push({
|
||||
rowElement: row,
|
||||
|
||||
Reference in New Issue
Block a user