fix(api): always return the page total when listing reports (#2534)

This commit is contained in:
Hampus
2026-09-06 17:38:21 +02:00
committed by GitHub
parent d2438b2fdd
commit 8f4fa82a9e
4 changed files with 22 additions and 28 deletions
@@ -74,7 +74,7 @@ export class AdminReportService {
const {reportService} = this.deps;
const requestedLimit = limit || 50;
const currentOffset = offset || 0;
const reports = await reportService.listReportsByStatus(status, requestedLimit, currentOffset);
const {reports, total} = await reportService.listReportsByStatus(status, requestedLimit, currentOffset);
const requestCache = createRequestCache();
const reportNsfwLookupCache = createReportNsfwLookupCache();
const reportResponses = await Promise.all(
@@ -84,6 +84,9 @@ export class AdminReportService {
);
return {
reports: reportResponses,
total,
offset: currentOffset,
limit: requestedLimit,
};
}
+9 -4
View File
@@ -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(