1
1
import { HttpClient , HttpParams } from "@angular/common/http" ;
2
2
import { Injectable , inject } from "@angular/core" ;
3
+ import { subDays } from "date-fns/subDays" ;
3
4
import { Observable } from "rxjs" ;
4
5
import { switchMap } from "rxjs/operators" ;
5
6
import { SETTINGS , Settings } from "../../settings" ;
6
7
import { LessonAbsence } from "../models/lesson-absence.model" ;
8
+ import { formatISOLocalDate } from "../utils/date" ;
7
9
import { decodeArray } from "../utils/decode" ;
8
10
import { RestService } from "./rest.service" ;
9
11
@@ -21,15 +23,17 @@ export class LessonTeachersRestService extends RestService<
21
23
}
22
24
23
25
/**
24
- * Returns all lesson absences for the current lesson and the specified students
26
+ * Returns all lesson absences CreatedOn after today-60 days and the specified students
25
27
* for all teachers except the specified teacher.
26
28
*/
27
29
loadOtherTeachersLessonAbsences (
28
30
personId : number ,
29
31
students : number [ ] ,
30
32
params ?: HttpParams | Dict < string > ,
31
33
) : Observable < ReadonlyArray < LessonAbsence > > {
32
- let url = `${ this . baseUrl } /except/${ personId } /LessonAbsences?expand=LessonRef` ;
34
+ const fromDate = subDays ( new Date ( ) , 60 ) ;
35
+
36
+ let url = `${ this . baseUrl } /except/${ personId } /LessonAbsences?expand=LessonRef&filter.CreatedOn=>${ formatISOLocalDate ( fromDate ) } ` ;
33
37
if ( students && students . length > 0 ) {
34
38
url = url . concat ( "&filter.StudentRef=;" + students . join ( ";" ) ) ;
35
39
}
0 commit comments