Skip to content

Commit 22a97e2

Browse files
committed
Iterate on getByDate
1 parent d42d74f commit 22a97e2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/components/periodic-report/periodic-report.gel.repository.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,30 @@ export class PeriodicReportGelRepository
6767
throw new Error('Method not implemented.');
6868
}
6969

70-
getByDate(
70+
async getByDate(
7171
parentId: ID,
7272
date: CalendarDate,
7373
reportType: ReportType,
7474
_session: Session,
7575
) {
76-
const resource = e.cast(e.Resource, e.uuid(parentId));
76+
const enhancedResource = EnhancedResource.of(
77+
resolveReportType({ type: reportType }),
78+
);
79+
const resource = e.cast(enhancedResource.db, e.uuid(parentId));
7780

78-
const report = e.select(e.PeriodicReport, (report) => ({
81+
const report = e.select(resource, (report) => ({
7982
filter: e.all(
8083
e.set(
8184
e.op(resource.id, '=', report.container.id),
8285
e.op(report.start, '<=', date),
8386
e.op(report.end, '>=', date),
8487
),
8588
),
86-
...report.is(resolveReportType(reportType)),
8789
}));
8890

89-
return this.db.run(report);
91+
const query = e.select(report, this.hydrate);
92+
93+
return await this.db.run(query);
9094
}
9195

9296
getCurrentDue(

0 commit comments

Comments
 (0)