refactor: enum casing (#19946)

This commit is contained in:
Jason Rasmussen
2025-07-15 14:50:13 -04:00
committed by GitHub
parent 920d7de349
commit e73abe0762
174 changed files with 2675 additions and 2459 deletions

View File

@@ -10,12 +10,12 @@ import { getCLIPModelInfo, isSmartSearchEnabled } from 'src/utils/misc';
@Injectable()
export class SmartInfoService extends BaseService {
@OnEvent({ name: 'ConfigInit', workers: [ImmichWorker.MICROSERVICES] })
@OnEvent({ name: 'ConfigInit', workers: [ImmichWorker.Microservices] })
async onConfigInit({ newConfig }: ArgOf<'ConfigInit'>) {
await this.init(newConfig);
}
@OnEvent({ name: 'ConfigUpdate', workers: [ImmichWorker.MICROSERVICES], server: true })
@OnEvent({ name: 'ConfigUpdate', workers: [ImmichWorker.Microservices], server: true })
async onConfigUpdate({ oldConfig, newConfig }: ArgOf<'ConfigUpdate'>) {
await this.init(newConfig, oldConfig);
}
@@ -64,11 +64,11 @@ export class SmartInfoService extends BaseService {
});
}
@OnJob({ name: JobName.QUEUE_SMART_SEARCH, queue: QueueName.SMART_SEARCH })
async handleQueueEncodeClip({ force }: JobOf<JobName.QUEUE_SMART_SEARCH>): Promise<JobStatus> {
@OnJob({ name: JobName.QueueSmartSearch, queue: QueueName.SmartSearch })
async handleQueueEncodeClip({ force }: JobOf<JobName.QueueSmartSearch>): Promise<JobStatus> {
const { machineLearning } = await this.getConfig({ withCache: false });
if (!isSmartSearchEnabled(machineLearning)) {
return JobStatus.SKIPPED;
return JobStatus.Skipped;
}
if (force) {
@@ -80,7 +80,7 @@ export class SmartInfoService extends BaseService {
let queue: JobItem[] = [];
const assets = this.assetJobRepository.streamForEncodeClip(force);
for await (const asset of assets) {
queue.push({ name: JobName.SMART_SEARCH, data: { id: asset.id } });
queue.push({ name: JobName.SmartSearch, data: { id: asset.id } });
if (queue.length >= JOBS_ASSET_PAGINATION_SIZE) {
await this.jobRepository.queueAll(queue);
queue = [];
@@ -89,23 +89,23 @@ export class SmartInfoService extends BaseService {
await this.jobRepository.queueAll(queue);
return JobStatus.SUCCESS;
return JobStatus.Success;
}
@OnJob({ name: JobName.SMART_SEARCH, queue: QueueName.SMART_SEARCH })
async handleEncodeClip({ id }: JobOf<JobName.SMART_SEARCH>): Promise<JobStatus> {
@OnJob({ name: JobName.SmartSearch, queue: QueueName.SmartSearch })
async handleEncodeClip({ id }: JobOf<JobName.SmartSearch>): Promise<JobStatus> {
const { machineLearning } = await this.getConfig({ withCache: true });
if (!isSmartSearchEnabled(machineLearning)) {
return JobStatus.SKIPPED;
return JobStatus.Skipped;
}
const asset = await this.assetJobRepository.getForClipEncoding(id);
if (!asset || asset.files.length !== 1) {
return JobStatus.FAILED;
return JobStatus.Failed;
}
if (asset.visibility === AssetVisibility.HIDDEN) {
return JobStatus.SKIPPED;
if (asset.visibility === AssetVisibility.Hidden) {
return JobStatus.Skipped;
}
const embedding = await this.machineLearningRepository.encodeImage(
@@ -122,11 +122,11 @@ export class SmartInfoService extends BaseService {
const newConfig = await this.getConfig({ withCache: true });
if (machineLearning.clip.modelName !== newConfig.machineLearning.clip.modelName) {
// Skip the job if the the model has changed since the embedding was generated.
return JobStatus.SKIPPED;
return JobStatus.Skipped;
}
await this.searchRepository.upsert(asset.id, embedding);
return JobStatus.SUCCESS;
return JobStatus.Success;
}
}