-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4aeaf58
commit 07d8f1b
Showing
2 changed files
with
212 additions
and
0 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
189 changes: 189 additions & 0 deletions
189
src/components/periodic-report/periodic-report.edgedb.repository.ts
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,189 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Query } from 'cypher-query-builder'; | ||
import { Without } from 'type-fest/source/merge-exclusive'; | ||
import { | ||
CalendarDate, | ||
ID, | ||
PublicOf, | ||
Range, | ||
Session, | ||
UnsecuredDto, | ||
} from '~/common'; | ||
import { castToEnum, e, RepoFor } from '~/core/edgedb'; | ||
import { Variable } from '../../core/database/query'; | ||
import { ProgressReport } from '../progress-report/dto'; | ||
import { | ||
FinancialReport, | ||
IPeriodicReport, | ||
MergePeriodicReports, | ||
NarrativeReport, | ||
ReportType, | ||
resolveReportType, | ||
} from './dto'; | ||
import { PeriodicReportRepository } from './periodic-report.repository'; | ||
|
||
@Injectable() | ||
export class PeriodicReportEdgeDBRepository | ||
extends RepoFor(IPeriodicReport, { | ||
hydrate: (periodicReport) => ({ | ||
...periodicReport['*'], | ||
type: castToEnum(periodicReport.__type__.name.slice(9, -7), ReportType), | ||
reportFile: true, | ||
sensitivity: periodicReport.container.is(e.Project.ContextAware) | ||
.sensitivity, | ||
scope: false, | ||
parent: e.tuple({ | ||
identity: periodicReport.id, | ||
labels: e.array_agg(e.set(periodicReport.__type__.name.slice(9, null))), | ||
properties: e.tuple({ | ||
id: periodicReport.id, | ||
createdAt: periodicReport.createdAt, | ||
}), | ||
}), | ||
}), | ||
}) | ||
implements PublicOf<PeriodicReportRepository> | ||
{ | ||
merge( | ||
input: MergePeriodicReports, | ||
): Promise<ReadonlyArray<{ id: ID; interval: Range<CalendarDate> }>> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
matchCurrentDue( | ||
parentId: ID | Variable, | ||
reportType: ReportType, | ||
): (query: Query) => Query { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
getByDate( | ||
Check failure on line 60 in src/components/periodic-report/periodic-report.edgedb.repository.ts GitHub Actions / lint
|
||
parentId: ID, | ||
date: CalendarDate, | ||
reportType: ReportType, | ||
_session: Session, | ||
) { | ||
const resource = e.cast(e.Resource, e.uuid(parentId)); | ||
|
||
const report = e.select(e.PeriodicReport, (report) => ({ | ||
filter: e.all( | ||
e.set( | ||
e.op(resource.id, '=', report.container.id), | ||
e.op(report.start, '<=', date), | ||
e.op(report.end, '>=', date), | ||
), | ||
), | ||
...report.is(resolveReportType(reportType)), | ||
Check failure on line 76 in src/components/periodic-report/periodic-report.edgedb.repository.ts GitHub Actions / lint
Check failure on line 76 in src/components/periodic-report/periodic-report.edgedb.repository.ts GitHub Actions / lint
|
||
})); | ||
|
||
return this.db.run(report); | ||
} | ||
|
||
getCurrentDue( | ||
parentId: ID, | ||
reportType: ReportType, | ||
session: Session, | ||
): Promise< | ||
| UnsecuredDto< | ||
| (Without< | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport), | ||
ProgressReport | ||
> & | ||
ProgressReport) | ||
| (Without< | ||
ProgressReport, | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
> & | ||
( | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
)) | ||
> | ||
| undefined | ||
> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
getNextDue( | ||
parentId: ID, | ||
reportType: ReportType, | ||
session: Session, | ||
): Promise< | ||
| UnsecuredDto< | ||
| (Without< | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport), | ||
ProgressReport | ||
> & | ||
ProgressReport) | ||
| (Without< | ||
ProgressReport, | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
> & | ||
( | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
)) | ||
> | ||
| undefined | ||
> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
getLatestReportSubmitted( | ||
parentId: ID, | ||
type: ReportType, | ||
session: Session, | ||
): Promise< | ||
| UnsecuredDto< | ||
| (Without< | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport), | ||
ProgressReport | ||
> & | ||
ProgressReport) | ||
| (Without< | ||
ProgressReport, | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
> & | ||
( | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
)) | ||
> | ||
| undefined | ||
> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
getFinalReport( | ||
parentId: ID, | ||
type: ReportType, | ||
session: Session, | ||
): Promise< | ||
| UnsecuredDto< | ||
| (Without< | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport), | ||
ProgressReport | ||
> & | ||
ProgressReport) | ||
| (Without< | ||
ProgressReport, | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
> & | ||
( | ||
| (Without<FinancialReport, NarrativeReport> & NarrativeReport) | ||
| (Without<NarrativeReport, FinancialReport> & FinancialReport) | ||
)) | ||
> | ||
| undefined | ||
> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |