Fix export offset (#13694)

* Use offset for export query

* Reduce loop count

* Add a line break for subsequent batches
This commit is contained in:
ian
2022-06-04 05:12:00 +08:00
committed by GitHub
parent d2d59903af
commit 6c1b95367f

View File

@@ -213,7 +213,7 @@ export class ExportService {
let readCount = 0;
for (let batch = 0; batch <= batchesRequired; batch++) {
for (let batch = 0; batch < batchesRequired; batch++) {
let limit = env.EXPORT_BATCH_SIZE;
if (requestedLimit > 0 && env.EXPORT_BATCH_SIZE > requestedLimit - readCount) {
@@ -223,7 +223,7 @@ export class ExportService {
const result = await service.readByQuery({
...query,
limit,
page: batch,
offset: batch * env.EXPORT_BATCH_SIZE,
});
readCount += result.length;
@@ -340,7 +340,13 @@ export class ExportService {
header: options?.includeHeader !== false,
});
return parser.parse(input);
let string = parser.parse(input);
if (options?.includeHeader === false) {
string = '\n' + string;
}
return string;
}
throw new ServiceUnavailableException(`Illegal export type used: "${format}"`, { service: 'export' });