summaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-05-25 21:34:51 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-05-25 21:34:51 +0200
commitc2317850bade3b4f8d4dfbf637a4e7f0428fe944 (patch)
tree84de82c6dcd99c3b68af0f8704bc873d8f226f3a /src/index.ts
parent3aa3f9f66cbb7c77c44eab53767c77811db50d79 (diff)
downloadsplus-c2317850bade3b4f8d4dfbf637a4e7f0428fe944.tar.gz
splus-c2317850bade3b4f8d4dfbf637a4e7f0428fe944.zip
Support multiple courses
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/index.ts b/src/index.ts
index 6de11de..a1e81a1 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -7,11 +7,12 @@ import {IEvent} from './core/IEvent';
import {ILecture} from './core/ILecture';
const range = (upper: number): number[] => Array.from(Array(upper), (x, i) => i)
+const xprod = (arr1, arr2) => [].concat(...arr1.map((e1) => arr2.map((e2) => [e1, e2])));
-async function main(configCourse, configPrefetchWeeks, configFilter) {
+async function main(configCourses, configPrefetchWeeks, configFilter) {
const baseDate = moment().startOf('week');
- await BPromise.map(range(configPrefetchWeeks), async weeksAhead => {
+ await BPromise.map(xprod(configCourses, range(configPrefetchWeeks)), async ([configCourse, weeksAhead]) => {
const unfilteredLectures = await SplusApi.getData(configCourse, baseDate.weeks() + weeksAhead);
const lectures = unfilteredLectures.filter(configFilter);
@@ -46,4 +47,4 @@ async function main(configCourse, configPrefetchWeeks, configFilter) {
await config.sink.commit();
}
-main(config.course, config.prefetchWeeks, config.lectureFilter).catch(console.log);
+main(config.courses, config.prefetchWeeks, config.lectureFilter).catch(console.log);