Fixing the error when importing a large Excel file

This commit is contained in:
2026-10-03 15:01:01 +03:30
parent f8313c0ea5
commit 2e315c9cfd
15 changed files with 503 additions and 86 deletions
@@ -15,6 +15,10 @@ import {
writeXlsx,
type ExcelPreviewResult,
} from '../common/excel';
import {
chunkImportMeta,
resolveExcelImportChunk,
} from '../common/excel-import-session';
import { ProjectBoardsService } from './project-boards.service';
const CASE_COLUMNS = [
@@ -115,16 +119,25 @@ export class ProjectCardsExcelService {
async import(
actor: Actor,
file: Express.Multer.File,
file: Express.Multer.File | undefined,
mappingRaw?: string,
chunk?: { sessionId?: string; offset?: string | number; limit?: string | number },
): Promise<ImportContactsResult> {
const rows = await readMappedRows(file, CASE_ALIASES, parseExcelMapping(mappingRaw));
const ctx = await resolveExcelImportChunk({
organizationId: actor.organizationId,
file,
sessionId: chunk?.sessionId,
offset: chunk?.offset,
limit: chunk?.limit,
loadRows: () =>
readMappedRows(file!, CASE_ALIASES, parseExcelMapping(mappingRaw)),
});
const result: ImportContactsResult = { created: 0, skipped: 0, errors: [] };
const affected = new Map<string, string>();
for (let i = 0; i < rows.length; i++) {
const row = rows[i]!;
const rowNum = i + 2;
for (let i = 0; i < ctx.slice.length; i++) {
const row = ctx.slice[i]!;
const rowNum = ctx.offset + i + 2;
if ((row._type || '').trim() && row._type.trim().toLowerCase() !== 'case') {
continue;
}
@@ -185,7 +198,7 @@ export class ProjectCardsExcelService {
result.boards = entries.map(([, n]) => n);
}
return result;
return { ...result, ...chunkImportMeta(ctx) };
}
private async resolveBoardAndStage(