mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
* wip * span class decorator fix typing * improvements * noisy postgres logs formatting * add source * strict string comparison Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * remove debug code * execution time histogram * remove prometheus stuff remove prometheus data * disable by default disable nestjs-otel stuff by default update imports * re-add postgres instrumentation formatting formatting * refactor: execution time histogram * decorator alias * formatting * keep original method order in filesystem repo * linting * enable otel sdk in e2e * actually enable otel sdk in e2e * share exclude paths * formatting * fix rebase * more buckets * add example setup * add envs fix actual fix * linting * update comments * update docker env * use more specific env --------- Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
25 lines
976 B
TypeScript
25 lines
976 B
TypeScript
import { ISystemMetadataRepository } from '@app/domain/repositories/system-metadata.repository';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { SystemMetadata, SystemMetadataEntity } from '../entities';
|
|
import { Instrumentation } from '../instrumentation';
|
|
|
|
@Instrumentation()
|
|
export class SystemMetadataRepository implements ISystemMetadataRepository {
|
|
constructor(
|
|
@InjectRepository(SystemMetadataEntity)
|
|
private repository: Repository<SystemMetadataEntity>,
|
|
) {}
|
|
|
|
async get<T extends keyof SystemMetadata>(key: T): Promise<SystemMetadata[T] | null> {
|
|
const metadata = await this.repository.findOne({ where: { key } });
|
|
if (!metadata) {
|
|
return null;
|
|
}
|
|
return metadata.value as SystemMetadata[T];
|
|
}
|
|
|
|
async set<T extends keyof SystemMetadata>(key: T, value: SystemMetadata[T]): Promise<void> {
|
|
await this.repository.upsert({ key, value }, { conflictPaths: { key: true } });
|
|
}
|
|
}
|