1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-21 18:16:55 +02:00

chore: better observability for geodata import (#13931)

This commit is contained in:
Zack Pollard 2024-11-05 16:20:56 +00:00 committed by GitHub
parent 5edbb93a4d
commit c383e115af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -249,6 +249,7 @@ export class MapRepository implements IMapRepository {
const input = createReadStream(filePath);
let bufferGeodata: QueryDeepPartialEntity<GeodataPlacesEntity>[] = [];
const lineReader = readLine.createInterface({ input });
let count = 0;
for await (const line of lineReader) {
const lineSplit = line.split('\t');
@ -257,8 +258,12 @@ export class MapRepository implements IMapRepository {
}
const geoData = lineToEntityMapper(lineSplit);
bufferGeodata.push(geoData);
if (bufferGeodata.length > 1000) {
if (bufferGeodata.length >= 1000) {
await queryRunner.manager.upsert(GeodataPlacesEntity, bufferGeodata, ['id']);
count += bufferGeodata.length;
if (count % 10_000 === 0) {
this.logger.log(`${count} geodata records imported`);
}
bufferGeodata = [];
}
}