mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
fix(api): always return the page total when listing reports (#2534)
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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