Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save e-learning venues as E-Learning in scraper #2823

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chrisgzf
Copy link
Member

@chrisgzf chrisgzf commented Aug 16, 2020

Follow up of #2736.

This PR changes the scraper to save lesson venues as "E-Learning" when the API returns a room of E-Learn_* for lessons.

To see current shaped of our scraped data: https://nusmods.com/api/v2/2020-2021/modules/CS1010.json

@ZhangYiJiang does this look right to you? Also would need some help to test this, if possible. 😅

Also, don't merge this yet. Still need to add the frontend changes.

@codecov
Copy link

codecov bot commented Aug 16, 2020

Codecov Report

Merging #2823 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2823   +/-   ##
=======================================
  Coverage   46.34%   46.34%           
=======================================
  Files         250      250           
  Lines        5302     5302           
  Branches     1220     1220           
=======================================
  Hits         2457     2457           
  Misses       2845     2845           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6da0ef1...b0514b1. Read the comment docs.

@@ -1,7 +1,8 @@
{
"compilerOptions": {
"outDir": "build",
"target": "es2020",
"target": "es2018",
"lib": ["dom", "es2020"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZhangYiJiang saw your comment about the target here #2784 (comment), I also added "dom" to lib because the URL() calls were throwing errors in my tests: Cannot find name 'URL'. Did you mean 'url'? Not sure if you've encountered this too but adding "dom" fixed this for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably not correct - this code will only be run in Node.js, and while dom lib will add URL as a global like in Node 10/12, it will also add a bunch of other globals like document and navigator which are not valid. The correct way to fix this is to use the @types/node typing, but it doesn't add globals unless it is imported at least once, so in the end it's probably best to just import URL explicitly import { URL } from 'url';

@nusmods-deploy-bot
Copy link

Comment on lines +1620 to +1622
CS4238Timetable.map((lesson) => {
return { ...lesson, room: 'E-Learn_C' };
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CS4238Timetable.map((lesson) => {
return { ...lesson, room: 'E-Learn_C' };
}),
CS4238Timetable.map((lesson) => ({ ...lesson, room: 'E-Learn_C' }));

@@ -111,7 +111,20 @@ export function transformModgrpToClassNo(modgrp: string, activity: string): stri
}

export function mapTimetableLesson(lesson: TimetableLesson, logger: Logger): TempRawLesson {
const { room, start_time, end_time, day, module, modgrp, activity, eventdate, csize } = lesson;
const {
room: providedRoom,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This avoids the || '' and ?. below

Suggested change
room: providedRoom,
room: providedRoom = '',

Copy link
Member

@taneliang taneliang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, one semester has passed. As zoning restrictions will be lifted on 6 Dec, I'm not sure how these venue names will change. Let's hold off work on this PR until we have more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants