mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
fix(api): always return the page total when listing reports (#2534)
This commit is contained in:
1 parent
d2438b2fdd
commit
8f4fa82a9e
4 files changed
+22
-28
No files matched your search
@@ -813,14 +813,19 @@ export class ReportService {
|
||||
return reports.filter((report): report is IARSubmission => report !== null);
|
||||
}
|
||||
|
||||
async listReportsByStatus(status: number, limit?: number, offset?: number): Promise<Array<IARSubmission>> {
|
||||
async listReportsByStatus(
|
||||
status: number,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
): Promise<{reports: Array<IARSubmission>; total: number}> {
|
||||
if (!this.reportSearchService) {
|
||||
throw new FeatureTemporarilyDisabledError();
|
||||
}
|
||||
const {hits} = await this.reportSearchService.listReportsByStatus(status, limit, offset);
|
||||
const {hits, total} = await this.reportSearchService.listReportsByStatus(status, limit, offset);
|
||||
const reportIds = hits.map((hit) => createReportID(BigInt(hit.id)));
|
||||
const reports = await Promise.all(reportIds.map((id) => this.reportRepository.getReport(id)));
|
||||
return reports.filter((report): report is IARSubmission => report !== null);
|
||||
const loaded = await Promise.all(reportIds.map((id) => this.reportRepository.getReport(id)));
|
||||
const reports = loaded.filter((report): report is IARSubmission => report !== null);
|
||||
return {reports, total: Math.max(0, total - (hits.length - reports.length))};
|
||||
}
|
||||
|
||||
async resolveReport(
|
||||
|
||||
Reference in new issue
Block a user