From b402ac0a08bd40a97837de7393674aa20edf9643 Mon Sep 17 00:00:00 2001 From: Jason Park Date: Fri, 2 Jun 2023 20:25:31 +0900 Subject: [PATCH] fix: applying hotfix changes to branch develop --- lib/configs/event/schedule.ts | 99 +++++++++++++++++++++------- src/lambda/syllabus-scraper/const.py | 2 +- src/lambda/syllabus-scraper/utils.py | 14 ++-- 3 files changed, 85 insertions(+), 30 deletions(-) diff --git a/lib/configs/event/schedule.ts b/lib/configs/event/schedule.ts index 535fcda51..58ac75882 100644 --- a/lib/configs/event/schedule.ts +++ b/lib/configs/event/schedule.ts @@ -1,26 +1,81 @@ import * as events from 'aws-cdk-lib/aws-events'; export const syllabusSchedule: { [name: string]: events.Schedule } = { - 'regular': - events.Schedule.cron({ minute: '0', hour: '16', day: '1', month: '*', year: '*' }), - 'fall-pre': - events.Schedule.cron({ minute: '0', hour: '16', day: '19,21,23', month: 'JUL,AUG', year: '*' }), - 'fall-reg1': - events.Schedule.cron({ minute: '0', hour: '16', day: '4,7,10,13,15,17', month: 'SEP', year: '*' }), - 'fall-reg2': - events.Schedule.cron({ minute: '0', hour: '16', day: '20,23,25', month: 'SEP', year: '*' }), - 'fall-reg3': - events.Schedule.cron({ minute: '0', hour: '16', day: '28,30', month: 'SEP', year: '*' }), - 'fall-reg4': - events.Schedule.cron({ minute: '0', hour: '16', day: '3,5,8', month: 'OCT', year: '*' }), - 'spring-pre': - events.Schedule.cron({ minute: '0', hour: '16', day: '14,24', month: 'FEB', year: '*' }), - 'spring-reg1': - events.Schedule.cron({ minute: '0', hour: '16', day: '4,7,10,13,16,18,21,24,27', month: 'MAR', year: '*' }), - 'spring-reg2': - events.Schedule.cron({ minute: '0', hour: '16', day: '3,5,8', month: 'APR', year: '*' }), - 'spring-reg3': - events.Schedule.cron({ minute: '0', hour: '16', day: '16,20,24,26,28', month: 'APR', year: '*' }), - 'spring-reg4': - events.Schedule.cron({ minute: '0', hour: '16', day: '9,12,14,16', month: 'MAY', year: '*' }), + 'regular': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '1,2', + month: '*', + year: '*', + }), + 'fall-pre': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '19,21,23', + month: 'JUL,AUG', + year: '*', + }), + 'fall-reg1': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '4,7,10,13,15,17', + month: 'SEP', + year: '*', + }), + 'fall-reg2': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '20,23,25', + month: 'SEP', + year: '*', + }), + 'fall-reg3': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '28,30', + month: 'SEP', + year: '*', + }), + 'fall-reg4': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '3,5,8', + month: 'OCT', + year: '*', + }), + 'spring-pre': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '14,24', + month: 'FEB', + year: '*', + }), + 'spring-reg1': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '4,7,10,13,16,18,21,24,27', + month: 'MAR', + year: '*', + }), + 'spring-reg2': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '3,5,8', + month: 'APR', + year: '*', + }), + 'spring-reg3': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '16,20,24,26,28', + month: 'APR', + year: '*', + }), + 'spring-reg4': events.Schedule.cron({ + minute: '0', + hour: '16', + day: '9,12,14,16', + month: 'MAY', + year: '*', + }), }; diff --git a/src/lambda/syllabus-scraper/const.py b/src/lambda/syllabus-scraper/const.py index 87cf93e4c..3afbdf6d6 100644 --- a/src/lambda/syllabus-scraper/const.py +++ b/src/lambda/syllabus-scraper/const.py @@ -237,6 +237,6 @@ cron_schedule = ["01-01", "02-01", "02-14", "02-24", "03-01", "03-04", "03-07", "03-10", "03-16", "03-18", "03-21", "03-24", "03-27", "04-01", "04-03", "04-05", "04-08", "04-16", "04-20", "04-24", "04-26", "04-28", - "05-01", "05-09", "05-12", "05-14", "05-16", "06-01", "07-01", "07-19", "07-21", "07-23", "08-01", + "05-01", "05-09", "05-12", "05-14", "05-16", "06-01", "06-02", "07-01", "07-19", "07-21", "07-23", "08-01", "08-19", "08-21", "08-23", "09-01", "09-04", "09-07", "09-10", "09-13", "09-15", "09-17", "09-20", "09-23", "09-25", "09-28", "09-30", "10-01", "10-03", "10-05", "10-08", "11-01", "12-01"] diff --git a/src/lambda/syllabus-scraper/utils.py b/src/lambda/syllabus-scraper/utils.py index 08c9be744..639b0222d 100644 --- a/src/lambda/syllabus-scraper/utils.py +++ b/src/lambda/syllabus-scraper/utils.py @@ -61,6 +61,11 @@ def to_half_width(s): return unicodedata.normalize('NFKC', s) +def remove_format_chars(line): + cleaned_line = re.sub(r'[\n\r\t]', ' ', line) + return cleaned_line + + def get_eval_criteria(parsed): """ Get the evaluation criteria from course detail page @@ -82,13 +87,13 @@ def get_eval_criteria(parsed): # Case 2: 2 or more rows for r in rows[1:]: elem = r.getchildren() - kind = elem[0].text_context() + kind = elem[0].text_content() percent = elem[1].text.strip()[:-1] or -1 try: percent = int(percent) except ValueError: logging.warning(f"Unable to parse percent: {percent}") - criteria = to_half_width(elem[2].text_context()) + criteria = to_half_width(elem[2].text_content()) cleaned_criteria = remove_format_chars(criteria) evals.append({ "t": to_enum(eval_type_map)(kind), @@ -351,8 +356,3 @@ def get_expire_date(): next_dt = cron_schedule[idx + 1].split('-') next_time = now.replace(month=int(next_dt[0]), day=int(next_dt[1])) return next_time - - -def remove_format_chars(line): - cleaned_line = re.sub(r'[\n\r\t]', ' ', line) - return cleaned_line