Skip to content

Commit

Permalink
fix: applying hotfix changes to branch develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonNotJson committed Jun 2, 2023
1 parent 571b629 commit b402ac0
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 30 deletions.
99 changes: 77 additions & 22 deletions lib/configs/event/schedule.ts
Original file line number Diff line number Diff line change
@@ -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: '*',
}),
};
2 changes: 1 addition & 1 deletion src/lambda/syllabus-scraper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
14 changes: 7 additions & 7 deletions src/lambda/syllabus-scraper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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

0 comments on commit b402ac0

Please sign in to comment.