Skip to content

Commit

Permalink
feat: added scrapedAt property (#149)
Browse files Browse the repository at this point in the history
* feat: added scrapedAt property

* fix: type-check
  • Loading branch information
sghsri authored Mar 12, 2024
1 parent 44af9e1 commit 8e181b3
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/check-types.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"prettier:fix": "prettier src --write",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives",
"lint:fix": "eslint src --ext ts,tsx --report-unused-disable-directives --fix",
"check-types": "tsc --noEmit",
"test": "vitest",
"test:ui": "vitest --ui",
"coverage": "vitest run --coverage",
Expand Down Expand Up @@ -116,4 +117,4 @@
"es-module-lexer": "^1.4.1"
}
}
}
}
5 changes: 5 additions & 0 deletions src/shared/types/Course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ export class Course {
instructionMode: InstructionMode;
/** Which semester is the course from */
semester: Semester;
/** Unix timestamp of when the course was last scraped */
scrapedAt: number;

constructor(course: Serialized<Course>) {
Object.assign(this, course);
this.schedule = new CourseSchedule(course.schedule);
this.instructors = course.instructors.map(i => new Instructor(i));
if (!course.scrapedAt) {
this.scrapedAt = Date.now();
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/stories/components/ConflictsWithWarning.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const ExampleCourse: Course = new Course({
status: Status.WAITLISTED,
uniqueId: 12345,
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
scrapedAt: Date.now(),
});
export const ExampleCourse2: Course = new Course({
courseName: 'PRINCIPLES OF COMPUTER SYSTEMS',
Expand Down Expand Up @@ -90,6 +91,7 @@ export const ExampleCourse2: Course = new Course({
status: Status.WAITLISTED,
uniqueId: 67890,
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
scrapedAt: Date.now(),
});

const meta = {
Expand Down
1 change: 1 addition & 0 deletions src/stories/components/List.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const generateCourses = (count: number): Course[] => {
courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB',
creditHours: 3,
department: 'C S',
scrapedAt: Date.now(),
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.',
'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.',
Expand Down
1 change: 1 addition & 0 deletions src/stories/components/PopupCourseBlock.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const ExampleCourse: Course = new Course({
courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB',
creditHours: 3,
department: 'C S',
scrapedAt: Date.now(),
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.',
'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.',
Expand Down
2 changes: 2 additions & 0 deletions src/stories/components/calendar/CalendarBottomBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const exampleGovCourse: Course = new Course({
schedule: {
meetings: [],
},
scrapedAt: Date.now(),
semester: {
code: '12345',
season: 'Spring',
Expand All @@ -43,6 +44,7 @@ const examplePsyCourse: Course = new Course({
flags: ['no flag for you >:)'],
fullName: 'PSY 317L Yada yada',
instructionMode: 'Online',
scrapedAt: Date.now(),
instructors: [
new Instructor({
firstName: 'Bevo',
Expand Down
1 change: 1 addition & 0 deletions src/stories/components/calendar/CalendarCourse.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const Default: Story = {
year: 2024,
season: 'Spring',
},
scrapedAt: Date.now(),
}),
meetingIdx: 0,
color: 'red',
Expand Down
3 changes: 3 additions & 0 deletions src/stories/components/calendar/CalendarSchedules.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const schedules = [
year: 2024,
season: 'Fall',
},
scrapedAt: Date.now(),
}),
],
name: 'Main Schedule',
Expand Down Expand Up @@ -98,6 +99,7 @@ const schedules = [
year: 2024,
season: 'Spring',
},
scrapedAt: Date.now(),
}),
new Course({
uniqueId: 123,
Expand Down Expand Up @@ -129,6 +131,7 @@ const schedules = [
year: 2024,
season: 'Fall',
},
scrapedAt: Date.now(),
}),
],
name: 'Backup #3',
Expand Down
3 changes: 3 additions & 0 deletions src/stories/injected/mocked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const exampleCourse: Course = new Course({
flags: ['Quantitative Reasoning'],
fullName: 'C S 303E ELEMS OF COMPTRS/PROGRAMMNG-WB',
instructionMode: 'Online',
scrapedAt: Date.now(),
instructors: [
new Instructor({
firstName: 'William',
Expand Down Expand Up @@ -100,6 +101,7 @@ export const bevoCourse: Course = new Course({
year: 2024,
season: 'Spring',
},
scrapedAt: Date.now(),
});

export const bevoScheule: UserSchedule = new UserSchedule({
Expand Down Expand Up @@ -151,6 +153,7 @@ export const MikeScottCS314Course: Course = new Course({
year: 2024,
season: 'Spring',
},
scrapedAt: Date.now(),
});

export const MikeScottCS314Schedule: UserSchedule = new UserSchedule({
Expand Down
1 change: 1 addition & 0 deletions src/views/lib/CourseCatalogScraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class CourseCatalogScraper {
instructors: this.getInstructors(row) as Instructor[],
description: this.getDescription(document),
semester: this.getSemester(),
scrapedAt: Date.now(),
});
courses.push({
element: row,
Expand Down

0 comments on commit 8e181b3

Please sign in to comment.