From a07e3de412d80a9aa56c580f2afe62025b0878f3 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Wed, 7 Feb 2018 16:29:00 +0100 Subject: Make getUsers easier to understand --- src/server/lib/getMeetingpointData.js | 46 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/server/lib/getMeetingpointData.js b/src/server/lib/getMeetingpointData.js index 34ed89f..b2225f4 100644 --- a/src/server/lib/getMeetingpointData.js +++ b/src/server/lib/getMeetingpointData.js @@ -14,27 +14,31 @@ function getUsers(page) { const regexs = [/var classes = \[(.+)\];/, /var teachers = \[(.+)\];/, /var rooms = \[(.+)\];/, /var students = \[(.+)\];/]; const items = regexs.map(regex => script.match(regex)[1].split(',').map(item => item.replace(/"/g, ''))); - return [] - .concat(items[0].map((item, index) => ({ - type: 'c', - value: item, - index, - }))) - .concat(items[1].map((item, index) => ({ - type: 't', - value: item, - index, - }))) - .concat(items[2].map((item, index) => ({ - type: 'r', - value: item, - index, - }))) - .concat(items[3].map((item, index) => ({ - type: 's', - value: item, - index, - }))); + const classes = items[0].map((item, index) => ({ + type: 'c', + value: item, + index, + })); + + const teachers = items[1].map((item, index) => ({ + type: 't', + value: item, + index, + })); + + const rooms = items[2].map((item, index) => ({ + type: 'r', + value: item, + index, + })); + + const students = items[3].map((item, index) => ({ + type: 's', + value: item, + index, + })); + + return _.flatten([classes, teachers, rooms, students]); } function getValidWeekNumbers(page) { -- cgit v1.1