diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-25 21:34:51 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-25 21:34:51 +0200 |
| commit | c2317850bade3b4f8d4dfbf637a4e7f0428fe944 (patch) | |
| tree | 84de82c6dcd99c3b68af0f8704bc873d8f226f3a /src/index.ts | |
| parent | 3aa3f9f66cbb7c77c44eab53767c77811db50d79 (diff) | |
| download | splus-c2317850bade3b4f8d4dfbf637a4e7f0428fe944.tar.gz splus-c2317850bade3b4f8d4dfbf637a4e7f0428fe944.zip | |
Support multiple courses
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 7 |
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); |
