@@ -3,6 +3,7 @@ import { Query } from 'cypher-query-builder';
3
3
import { Without } from 'type-fest/source/merge-exclusive' ;
4
4
import {
5
5
CalendarDate ,
6
+ EnhancedResource ,
6
7
ID ,
7
8
PublicOf ,
8
9
Range ,
@@ -57,26 +58,30 @@ export class PeriodicReportEdgeDBRepository
57
58
throw new Error ( 'Method not implemented.' ) ;
58
59
}
59
60
60
- getByDate (
61
+ async getByDate (
61
62
parentId : ID ,
62
63
date : CalendarDate ,
63
64
reportType : ReportType ,
64
65
_session : Session ,
65
66
) {
66
- const resource = e . cast ( e . Resource , e . uuid ( parentId ) ) ;
67
+ const enhancedResource = EnhancedResource . of (
68
+ resolveReportType ( { type : reportType } ) ,
69
+ ) ;
70
+ const resource = e . cast ( enhancedResource . db , e . uuid ( parentId ) ) ;
67
71
68
- const report = e . select ( e . PeriodicReport , ( report ) => ( {
72
+ const report = e . select ( resource , ( report ) => ( {
69
73
filter : e . all (
70
74
e . set (
71
75
e . op ( resource . id , '=' , report . container . id ) ,
72
76
e . op ( report . start , '<=' , date ) ,
73
77
e . op ( report . end , '>=' , date ) ,
74
78
) ,
75
79
) ,
76
- ...report . is ( resolveReportType ( reportType ) ) ,
77
80
} ) ) ;
78
81
79
- return this . db . run ( report ) ;
82
+ const query = e . select ( report , this . hydrate ) ;
83
+
84
+ return await this . db . run ( query ) ;
80
85
}
81
86
82
87
getCurrentDue (
0 commit comments