fix: reports not reporting all possible reports (#5933)
* Fix Reports page only giving 695 reports due to Labrinth Issue Basically, for some reason, Labrinth returns 5 less depending on the amount requested and the offset position, leading to the end of all reports, even if it's not correct. Signed-off-by: Blodhgarm <timekeeperguild@gmail.com> * remove constant condition --------- Signed-off-by: Blodhgarm <timekeeperguild@gmail.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
@@ -103,12 +103,16 @@ const { data: allReports } = await useLazyAsyncData('new-moderation-reports', as
|
|||||||
const enrichmentPromises: Promise<ExtendedReport[]>[] = []
|
const enrichmentPromises: Promise<ExtendedReport[]>[] = []
|
||||||
|
|
||||||
let reports: Report[]
|
let reports: Report[]
|
||||||
do {
|
let hasMoreReports = true
|
||||||
|
while (hasMoreReports) {
|
||||||
reports = (await useBaseFetch(`report?count=${REPORT_ENDPOINT_COUNT}&offset=${currentOffset}`, {
|
reports = (await useBaseFetch(`report?count=${REPORT_ENDPOINT_COUNT}&offset=${currentOffset}`, {
|
||||||
apiVersion: 3,
|
apiVersion: 3,
|
||||||
})) as Report[]
|
})) as Report[]
|
||||||
|
|
||||||
if (reports.length === 0) break
|
hasMoreReports = reports.length > 0
|
||||||
|
if (!hasMoreReports) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
const enrichmentPromise = enrichReportBatch(reports)
|
const enrichmentPromise = enrichReportBatch(reports)
|
||||||
enrichmentPromises.push(enrichmentPromise)
|
enrichmentPromises.push(enrichmentPromise)
|
||||||
@@ -119,7 +123,7 @@ const { data: allReports } = await useLazyAsyncData('new-moderation-reports', as
|
|||||||
const completed = await Promise.all(enrichmentPromises.splice(0, 2))
|
const completed = await Promise.all(enrichmentPromises.splice(0, 2))
|
||||||
allReports.push(...completed.flat())
|
allReports.push(...completed.flat())
|
||||||
}
|
}
|
||||||
} while (reports.length === REPORT_ENDPOINT_COUNT)
|
}
|
||||||
|
|
||||||
const remainingBatches = await Promise.all(enrichmentPromises)
|
const remainingBatches = await Promise.all(enrichmentPromises)
|
||||||
allReports.push(...remainingBatches.flat())
|
allReports.push(...remainingBatches.flat())
|
||||||
|
|||||||
Reference in New Issue
Block a user