diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-02-07 16:29:00 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-02-07 16:29:00 +0100 |
commit | a07e3de412d80a9aa56c580f2afe62025b0878f3 (patch) | |
tree | e0f667b289d6dd209b4fc15cc48319fc8b6d9541 /src | |
parent | 5a11784a039c917c2c6e70d59d97ad439e5f0c35 (diff) |
Make getUsers easier to understand
Diffstat (limited to 'src')
-rw-r--r-- | src/server/lib/getMeetingpointData.js | 46 |
1 files changed, 25 insertions, 21 deletions
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) { |