-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added bull queue lessons processing * ci: who uses these anyways 🧌 * feat: added redis unix socket support
- Loading branch information
Showing
10 changed files
with
302 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Process, Processor } from '@nestjs/bull'; | ||
import { Job } from 'bull'; | ||
import { UntisService } from 'src/untis/untis.service'; | ||
import { LessonsService } from './lessons.service'; | ||
|
||
export interface FetchData { | ||
before: number; | ||
after: number; | ||
classId: number; | ||
} | ||
|
||
export interface FetchIcsData { | ||
before: number; | ||
after: number; | ||
classId: number; | ||
includedSubjects?: number[]; | ||
excludedSubjects?: number[]; | ||
alarms?: number[]; | ||
offset?: number; | ||
} | ||
|
||
@Processor('lessons-queue') | ||
export class LessonsProcessor { | ||
constructor( | ||
private readonly untisService: UntisService, | ||
private readonly lessonsService: LessonsService, | ||
) {} | ||
|
||
@Process('fetch') | ||
async handleFetch(job: Job<FetchData>) { | ||
const { before, after, classId } = job.data; | ||
const lessons = await this.untisService.fetchTimetable( | ||
before, | ||
after, | ||
classId, | ||
); | ||
await job.progress(100); | ||
return lessons; | ||
} | ||
|
||
@Process('fetch-ics') | ||
async handleFetchIcs(job: Job<FetchIcsData>) { | ||
const { | ||
before, | ||
after, | ||
classId, | ||
includedSubjects, | ||
excludedSubjects, | ||
alarms, | ||
offset, | ||
} = job.data; | ||
const lessons = await this.untisService.fetchTimetable( | ||
before, | ||
after, | ||
classId, | ||
); | ||
await job.progress(50); | ||
const ics = await this.lessonsService.convertToEvents(lessons, { | ||
includedSubjects, | ||
excludedSubjects, | ||
alarms, | ||
offset, | ||
}); | ||
await job.progress(100); | ||
return ics; | ||
} | ||
} |
Oops, something went wrong.