aboutsummaryrefslogtreecommitdiff
path: root/src/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/lib')
-rw-r--r--src/server/lib/getMeetingpointData.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/server/lib/getMeetingpointData.js b/src/server/lib/getMeetingpointData.js
index 69d518f..64e8500 100644
--- a/src/server/lib/getMeetingpointData.js
+++ b/src/server/lib/getMeetingpointData.js
@@ -52,6 +52,10 @@ function getWeeks(page) {
return weeks;
}
+function getAltText(page) {
+ return page('center > font').eq(2).text().trim();
+}
+
function requestData() {
lastUpdate = new Date();
@@ -71,13 +75,14 @@ function requestData() {
const teachers = users.filter(user => user.type === 't');
const teacherRequests = teachers.map(teacher =>
- request(getUrlOfUser('dag', teacher.type, teacher.index, 7), { timeout: 5000, encoding: null }));
+ request(getUrlOfUser('dag', teacher.type, teacher.index, 7), { encoding: null }));
return Promise.all(teacherRequests).then((teacherResponses) => {
const teachersWithAlts = teacherResponses.map((teacherResponse, index) => {
const utf8Body = iconv.decode(teacherResponse.body, 'iso-8859-1');
const teacherResponseBody = cheerio.load(utf8Body);
- const teacherName = teacherResponseBody('center > font').eq(2).text().trim();
+
+ const teacherName = getAltText(teacherResponseBody);
return {
...teachers[index],
@@ -86,7 +91,7 @@ function requestData() {
});
meetingpointData = {
- users: _.defaults(teachersWithAlts, users),
+ users: _.uniqBy(_.flatten([teachersWithAlts, users]), user => `${user.type}/${user.value}`),
dailyScheduleWeeks,
basisScheduleWeeks,
};