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:
parent
5edbb93a4d
commit
c383e115af
@ -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 = [];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user