feat: added scrapedAt property (#149)

* feat: added scrapedAt property

* fix: type-check
This commit is contained in:
Sriram Hariharan
2024-03-12 00:57:00 -05:00
committed by GitHub
parent 44af9e16e4
commit 8e181b3010
11 changed files with 45 additions and 1 deletions

24
.github/workflows/check-types.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Type Check
on: [push, pull_request]
jobs:
type-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
- name: Install dependencies
run: pnpm install
- name: Run tests
run: pnpm run check-types

View File

@@ -13,6 +13,7 @@
"prettier:fix": "prettier src --write", "prettier:fix": "prettier src --write",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives",
"lint:fix": "eslint src --ext ts,tsx --report-unused-disable-directives --fix", "lint:fix": "eslint src --ext ts,tsx --report-unused-disable-directives --fix",
"check-types": "tsc --noEmit",
"test": "vitest", "test": "vitest",
"test:ui": "vitest --ui", "test:ui": "vitest --ui",
"coverage": "vitest run --coverage", "coverage": "vitest run --coverage",
@@ -116,4 +117,4 @@
"es-module-lexer": "^1.4.1" "es-module-lexer": "^1.4.1"
} }
} }
} }

View File

@@ -73,11 +73,16 @@ export class Course {
instructionMode: InstructionMode; instructionMode: InstructionMode;
/** Which semester is the course from */ /** Which semester is the course from */
semester: Semester; semester: Semester;
/** Unix timestamp of when the course was last scraped */
scrapedAt: number;
constructor(course: Serialized<Course>) { constructor(course: Serialized<Course>) {
Object.assign(this, course); Object.assign(this, course);
this.schedule = new CourseSchedule(course.schedule); this.schedule = new CourseSchedule(course.schedule);
this.instructors = course.instructors.map(i => new Instructor(i)); this.instructors = course.instructors.map(i => new Instructor(i));
if (!course.scrapedAt) {
this.scrapedAt = Date.now();
}
} }
/** /**

View File

@@ -44,6 +44,7 @@ export const ExampleCourse: Course = new Course({
status: Status.WAITLISTED, status: Status.WAITLISTED,
uniqueId: 12345, uniqueId: 12345,
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/', url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
scrapedAt: Date.now(),
}); });
export const ExampleCourse2: Course = new Course({ export const ExampleCourse2: Course = new Course({
courseName: 'PRINCIPLES OF COMPUTER SYSTEMS', courseName: 'PRINCIPLES OF COMPUTER SYSTEMS',
@@ -90,6 +91,7 @@ export const ExampleCourse2: Course = new Course({
status: Status.WAITLISTED, status: Status.WAITLISTED,
uniqueId: 67890, uniqueId: 67890,
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/', url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
scrapedAt: Date.now(),
}); });
const meta = { const meta = {

View File

@@ -25,6 +25,7 @@ const generateCourses = (count: number): Course[] => {
courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB', courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB',
creditHours: 3, creditHours: 3,
department: 'C S', department: 'C S',
scrapedAt: Date.now(),
description: [ description: [
'Problem solving and fundamental algorithms for various applications in science, business, and on the World Wide Web, and introductory programming in a modern object-oriented programming language.', 'Problem solving and fundamental algorithms for various applications in science, business, and on the World Wide Web, and introductory programming in a modern object-oriented programming language.',
'Only one of the following may be counted: Computer Science 303E, 312, 312H. Credit for Computer Science 303E may not be earned after a student has received credit for Computer Science 314, or 314H. May not be counted toward a degree in computer science.', 'Only one of the following may be counted: Computer Science 303E, 312, 312H. Credit for Computer Science 303E may not be earned after a student has received credit for Computer Science 314, or 314H. May not be counted toward a degree in computer science.',

View File

@@ -17,6 +17,7 @@ export const ExampleCourse: Course = new Course({
courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB', courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB',
creditHours: 3, creditHours: 3,
department: 'C S', department: 'C S',
scrapedAt: Date.now(),
description: [ description: [
'Problem solving and fundamental algorithms for various applications in science, business, and on the World Wide Web, and introductory programming in a modern object-oriented programming language.', 'Problem solving and fundamental algorithms for various applications in science, business, and on the World Wide Web, and introductory programming in a modern object-oriented programming language.',
'Only one of the following may be counted: Computer Science 303E, 312, 312H. Credit for Computer Science 303E may not be earned after a student has received credit for Computer Science 314, or 314H. May not be counted toward a degree in computer science.', 'Only one of the following may be counted: Computer Science 303E, 312, 312H. Credit for Computer Science 303E may not be earned after a student has received credit for Computer Science 314, or 314H. May not be counted toward a degree in computer science.',

View File

@@ -25,6 +25,7 @@ const exampleGovCourse: Course = new Course({
schedule: { schedule: {
meetings: [], meetings: [],
}, },
scrapedAt: Date.now(),
semester: { semester: {
code: '12345', code: '12345',
season: 'Spring', season: 'Spring',
@@ -43,6 +44,7 @@ const examplePsyCourse: Course = new Course({
flags: ['no flag for you >:)'], flags: ['no flag for you >:)'],
fullName: 'PSY 317L Yada yada', fullName: 'PSY 317L Yada yada',
instructionMode: 'Online', instructionMode: 'Online',
scrapedAt: Date.now(),
instructors: [ instructors: [
new Instructor({ new Instructor({
firstName: 'Bevo', firstName: 'Bevo',

View File

@@ -55,6 +55,7 @@ export const Default: Story = {
year: 2024, year: 2024,
season: 'Spring', season: 'Spring',
}, },
scrapedAt: Date.now(),
}), }),
meetingIdx: 0, meetingIdx: 0,
color: 'red', color: 'red',

View File

@@ -61,6 +61,7 @@ const schedules = [
year: 2024, year: 2024,
season: 'Fall', season: 'Fall',
}, },
scrapedAt: Date.now(),
}), }),
], ],
name: 'Main Schedule', name: 'Main Schedule',
@@ -98,6 +99,7 @@ const schedules = [
year: 2024, year: 2024,
season: 'Spring', season: 'Spring',
}, },
scrapedAt: Date.now(),
}), }),
new Course({ new Course({
uniqueId: 123, uniqueId: 123,
@@ -129,6 +131,7 @@ const schedules = [
year: 2024, year: 2024,
season: 'Fall', season: 'Fall',
}, },
scrapedAt: Date.now(),
}), }),
], ],
name: 'Backup #3', name: 'Backup #3',

View File

@@ -17,6 +17,7 @@ export const exampleCourse: Course = new Course({
flags: ['Quantitative Reasoning'], flags: ['Quantitative Reasoning'],
fullName: 'C S 303E ELEMS OF COMPTRS/PROGRAMMNG-WB', fullName: 'C S 303E ELEMS OF COMPTRS/PROGRAMMNG-WB',
instructionMode: 'Online', instructionMode: 'Online',
scrapedAt: Date.now(),
instructors: [ instructors: [
new Instructor({ new Instructor({
firstName: 'William', firstName: 'William',
@@ -100,6 +101,7 @@ export const bevoCourse: Course = new Course({
year: 2024, year: 2024,
season: 'Spring', season: 'Spring',
}, },
scrapedAt: Date.now(),
}); });
export const bevoScheule: UserSchedule = new UserSchedule({ export const bevoScheule: UserSchedule = new UserSchedule({
@@ -151,6 +153,7 @@ export const MikeScottCS314Course: Course = new Course({
year: 2024, year: 2024,
season: 'Spring', season: 'Spring',
}, },
scrapedAt: Date.now(),
}); });
export const MikeScottCS314Schedule: UserSchedule = new UserSchedule({ export const MikeScottCS314Schedule: UserSchedule = new UserSchedule({

View File

@@ -92,6 +92,7 @@ export class CourseCatalogScraper {
instructors: this.getInstructors(row) as Instructor[], instructors: this.getInstructors(row) as Instructor[],
description: this.getDescription(document), description: this.getDescription(document),
semester: this.getSemester(), semester: this.getSemester(),
scrapedAt: Date.now(),
}); });
courses.push({ courses.push({
element: row, element: row,