mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix export offset (#13694)
* Use offset for export query * Reduce loop count * Add a line break for subsequent batches
This commit is contained in:
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user