|
|
|
|
@ -1,4 +1,9 @@
|
|
|
|
|
import {
|
|
|
|
|
citiesFile,
|
|
|
|
|
geodataAdmin1Path,
|
|
|
|
|
geodataAdmin2Path,
|
|
|
|
|
geodataCitites500Path,
|
|
|
|
|
geodataDatePath,
|
|
|
|
|
GeoPoint,
|
|
|
|
|
IMetadataRepository,
|
|
|
|
|
ImmichTags,
|
|
|
|
|
@ -20,8 +25,6 @@ import { DataSource, DeepPartial, QueryRunner, Repository } from 'typeorm';
|
|
|
|
|
type GeoEntity = GeodataPlacesEntity | GeodataAdmin1Entity | GeodataAdmin2Entity;
|
|
|
|
|
type GeoEntityClass = typeof GeodataPlacesEntity | typeof GeodataAdmin1Entity | typeof GeodataAdmin2Entity;
|
|
|
|
|
|
|
|
|
|
const CITIES_FILE = 'cities500.txt';
|
|
|
|
|
|
|
|
|
|
export class MetadataRepository implements IMetadataRepository {
|
|
|
|
|
constructor(
|
|
|
|
|
@InjectRepository(GeodataPlacesEntity) private readonly geodataPlacesRepository: Repository<GeodataPlacesEntity>,
|
|
|
|
|
@ -35,7 +38,7 @@ export class MetadataRepository implements IMetadataRepository {
|
|
|
|
|
|
|
|
|
|
async init(): Promise<void> {
|
|
|
|
|
this.logger.log('Initializing metadata repository');
|
|
|
|
|
const geodataDate = await readFile('/usr/src/resources/geodata-date.txt', 'utf8');
|
|
|
|
|
const geodataDate = await readFile(geodataDatePath, 'utf8');
|
|
|
|
|
|
|
|
|
|
const geocodingMetadata = await this.systemMetadataRepository.get(SystemMetadataKey.REVERSE_GEOCODING_STATE);
|
|
|
|
|
|
|
|
|
|
@ -48,7 +51,7 @@ export class MetadataRepository implements IMetadataRepository {
|
|
|
|
|
|
|
|
|
|
await this.systemMetadataRepository.set(SystemMetadataKey.REVERSE_GEOCODING_STATE, {
|
|
|
|
|
lastUpdate: geodataDate,
|
|
|
|
|
lastImportFileName: CITIES_FILE,
|
|
|
|
|
lastImportFileName: citiesFile,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.logger.log('Geodata import completed');
|
|
|
|
|
@ -116,7 +119,7 @@ export class MetadataRepository implements IMetadataRepository {
|
|
|
|
|
admin2Code: lineSplit[11],
|
|
|
|
|
modificationDate: lineSplit[18],
|
|
|
|
|
}),
|
|
|
|
|
`/usr/src/resources/${CITIES_FILE}`,
|
|
|
|
|
geodataCitites500Path,
|
|
|
|
|
GeodataPlacesEntity,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -129,7 +132,7 @@ export class MetadataRepository implements IMetadataRepository {
|
|
|
|
|
key: lineSplit[0],
|
|
|
|
|
name: lineSplit[1],
|
|
|
|
|
}),
|
|
|
|
|
'/usr/src/resources/admin1CodesASCII.txt',
|
|
|
|
|
geodataAdmin1Path,
|
|
|
|
|
GeodataAdmin1Entity,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -142,7 +145,7 @@ export class MetadataRepository implements IMetadataRepository {
|
|
|
|
|
key: lineSplit[0],
|
|
|
|
|
name: lineSplit[1],
|
|
|
|
|
}),
|
|
|
|
|
'/usr/src/resources/admin2Codes.txt',
|
|
|
|
|
geodataAdmin2Path,
|
|
|
|
|
GeodataAdmin2Entity,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|