From b4b131a0e5c2d743d1bbd903667134acd6d38953 Mon Sep 17 00:00:00 2001 From: Zack Pollard Date: Tue, 5 Nov 2024 15:49:18 +0000 Subject: [PATCH] chore: better observability for geodata import --- server/src/repositories/map.repository.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/repositories/map.repository.ts b/server/src/repositories/map.repository.ts index 7ad94016e8667e..f28af65fa93367 100644 --- a/server/src/repositories/map.repository.ts +++ b/server/src/repositories/map.repository.ts @@ -249,6 +249,7 @@ export class MapRepository implements IMapRepository { const input = createReadStream(filePath); let bufferGeodata: QueryDeepPartialEntity[] = []; const lineReader = readLine.createInterface({ input }); + let count = 0; for await (const line of lineReader) { const lineSplit = line.split('\t'); @@ -257,8 +258,10 @@ export class MapRepository implements IMapRepository { } const geoData = lineToEntityMapper(lineSplit); bufferGeodata.push(geoData); - if (bufferGeodata.length > 1000) { + ++count; + if (bufferGeodata.length >= 1000) { await queryRunner.manager.upsert(GeodataPlacesEntity, bufferGeodata, ['id']); + this.logger.log(`${count} geodata records imported`); bufferGeodata = []; } }