aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2022-08-08 01:41:56 -0500
committerFurkan Sahin <furkan-dev@proton.me>2022-08-08 01:41:56 -0500
commit7cd4559fea46f0b9be5c9604fa45644fd084a281 (patch)
treebd8f98159d27687ce366afc718e7b7fddcae9a45 /src/util
parent4974eb40dd230a0ae58ba7c4e8c5be635ae19a02 (diff)
`parseOfficeHours` works correctly now. PT office hours can now be automatically parsed (if using strawpoll). Also displaying office hours in TAMU HTML Output page
Diffstat (limited to 'src/util')
-rw-r--r--src/util/parser.ts26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/util/parser.ts b/src/util/parser.ts
index 1daf113..0e2ebbf 100644
--- a/src/util/parser.ts
+++ b/src/util/parser.ts
@@ -266,10 +266,32 @@ export function parseOfficeHours(csv: string) {
for (let i = begin + 1; i < end; i++) {
const pt_uin = parseInt(sheet[i][0]);
const pt = pts.get(pt_uin);
- if (pt != undefined || pt != null) {
+ if (pt != undefined && pt != null)
pt.office_hours = parseStrawpollTimesEntry(sheet[i], sheet[begin]);
- }
}
+
+
+ // Merge office hours that take place during the same time of day
+ pts.forEach((pt) => {
+ if (pt.office_hours != undefined && pt.office_hours != null) {
+ const flag = {};
+ const unique: EventInfo[] = [];
+ pt.office_hours.forEach((curr_event) => {
+ const key = `${curr_event.start}${curr_event.end}`;
+ if (!flag[key]) {
+ flag[key] = true;
+ unique.push(curr_event);
+ }
+ else {
+ const head_event = unique.find((val) => {
+ return val.start === curr_event.start && val.end === curr_event.end;
+ })
+ head_event.days += curr_event.days;
+ }
+ })
+ pt.office_hours = unique;
+ }
+ });
}
/**