aboutsummaryrefslogtreecommitdiff
path: root/src/server/routes/getSchedule.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-07-07 17:34:02 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-07-07 17:34:02 +0200
commit5c265c04ad513d845a41c7866c3ed231c8d5e68e (patch)
tree9a86b66958e59e4a07d0c8e10731667b05990816 /src/server/routes/getSchedule.js
parent8b1f29f2802a081a67151e47b9c52803d7cc568a (diff)
server: Use database for userssync-with-db
Diffstat (limited to 'src/server/routes/getSchedule.js')
-rw-r--r--src/server/routes/getSchedule.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/server/routes/getSchedule.js b/src/server/routes/getSchedule.js
index 2ade31a..fb78e97 100644
--- a/src/server/routes/getSchedule.js
+++ b/src/server/routes/getSchedule.js
@@ -22,10 +22,10 @@ const express = require('express');
const router = express.Router();
-const getScheduleData = require('../lib/schools/hetmml/getScheduleData');
-const getURLOfUser = require('../lib/schools/hetmml/getURLOfUser');
-const axios = require('../lib/schools/hetmml/axios');
-const parseSchedule = require('../lib/schools/hetmml/parseSchedule');
+const { getUsers } = require('../../shared/lib/db');
+const getURLOfUser = require('../../shared/lib/getURLOfUser');
+const axios = require('../../shared/lib/axios');
+const parseSchedule = require('../lib/parseSchedule');
// copied from http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/untisscripts.js,
// were using the same code as they do to be sure that we always get the same
@@ -46,14 +46,14 @@ function currentWeekNumber() {
return 1 + Math.ceil((firstThursday - target) / 604800000);
}
-async function getSchedule(userType, userValue, week, scheduleType = 'dag') {
- const { users } = await getScheduleData();
+async function getSchedule(userType, userName, week, scheduleType = 'dag') {
+ const users = await getUsers();
const user = users.filter(user_ => (
- user_.type === userType && user_.value === userValue
+ user_.type === userType && user_.name === userName
))[0];
if (!user) {
- throw new Error(`${userType}/${userValue} is not in the user index.`);
+ throw new Error(`${userType}/${userName} is not in the user index.`);
}
if (!week) {