2023-05-17 19:07:17 +02:00
|
|
|
import { AlbumEntity, AssetEntity, AssetFaceEntity } from '@app/infra/entities';
|
2023-08-25 06:15:03 +02:00
|
|
|
import { Inject, Injectable, Logger } from '@nestjs/common';
|
2023-08-11 18:00:51 +02:00
|
|
|
import { mapAlbumWithAssets } from '../album';
|
2023-03-03 03:47:08 +01:00
|
|
|
import { IAlbumRepository } from '../album/album.repository';
|
2023-05-28 03:56:17 +02:00
|
|
|
import { AssetResponseDto, mapAsset } from '../asset';
|
2023-03-03 03:47:08 +01:00
|
|
|
import { IAssetRepository } from '../asset/asset.repository';
|
|
|
|
import { AuthUserDto } from '../auth';
|
2023-05-22 20:05:06 +02:00
|
|
|
import { usePagination } from '../domain.util';
|
2023-09-04 21:45:59 +02:00
|
|
|
import { IAssetFaceJob, IBulkEntityJob, IJobRepository, JOBS_ASSET_PAGINATION_SIZE, JobName } from '../job';
|
2023-09-27 22:46:46 +02:00
|
|
|
import { AssetFaceId, IPersonRepository } from '../person';
|
2023-03-18 14:44:42 +01:00
|
|
|
import { IMachineLearningRepository } from '../smart-info';
|
2023-08-25 06:15:03 +02:00
|
|
|
import { FeatureFlag, ISystemConfigRepository, SystemConfigCore } from '../system-config';
|
2023-03-03 03:47:08 +01:00
|
|
|
import { SearchDto } from './dto';
|
2023-08-25 06:15:03 +02:00
|
|
|
import { SearchResponseDto } from './response-dto';
|
2023-03-18 14:44:42 +01:00
|
|
|
import {
|
|
|
|
ISearchRepository,
|
2023-05-17 19:07:17 +02:00
|
|
|
OwnedFaceEntity,
|
2023-03-18 14:44:42 +01:00
|
|
|
SearchCollection,
|
|
|
|
SearchExploreItem,
|
|
|
|
SearchResult,
|
|
|
|
SearchStrategy,
|
|
|
|
} from './search.repository';
|
|
|
|
|
|
|
|
interface SyncQueue {
|
|
|
|
upsert: Set<string>;
|
|
|
|
delete: Set<string>;
|
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class SearchService {
|
|
|
|
private logger = new Logger(SearchService.name);
|
2023-08-25 06:15:03 +02:00
|
|
|
private enabled = false;
|
2023-08-28 21:41:57 +02:00
|
|
|
private timer: NodeJS.Timeout | null = null;
|
2023-08-25 06:15:03 +02:00
|
|
|
private configCore: SystemConfigCore;
|
2023-03-18 14:44:42 +01:00
|
|
|
|
|
|
|
private albumQueue: SyncQueue = {
|
|
|
|
upsert: new Set(),
|
|
|
|
delete: new Set(),
|
|
|
|
};
|
|
|
|
|
|
|
|
private assetQueue: SyncQueue = {
|
|
|
|
upsert: new Set(),
|
|
|
|
delete: new Set(),
|
|
|
|
};
|
2023-03-03 03:47:08 +01:00
|
|
|
|
2023-05-17 19:07:17 +02:00
|
|
|
private faceQueue: SyncQueue = {
|
|
|
|
upsert: new Set(),
|
|
|
|
delete: new Set(),
|
|
|
|
};
|
|
|
|
|
2023-03-03 03:47:08 +01:00
|
|
|
constructor(
|
|
|
|
@Inject(IAlbumRepository) private albumRepository: IAlbumRepository,
|
|
|
|
@Inject(IAssetRepository) private assetRepository: IAssetRepository,
|
|
|
|
@Inject(IJobRepository) private jobRepository: IJobRepository,
|
2023-03-18 14:44:42 +01:00
|
|
|
@Inject(IMachineLearningRepository) private machineLearning: IMachineLearningRepository,
|
2023-09-27 22:46:46 +02:00
|
|
|
@Inject(IPersonRepository) private personRepository: IPersonRepository,
|
2023-03-03 03:47:08 +01:00
|
|
|
@Inject(ISearchRepository) private searchRepository: ISearchRepository,
|
2023-09-27 22:46:46 +02:00
|
|
|
@Inject(ISystemConfigRepository) configRepository: ISystemConfigRepository,
|
2023-03-03 03:47:08 +01:00
|
|
|
) {
|
2023-10-09 02:51:03 +02:00
|
|
|
this.configCore = SystemConfigCore.create(configRepository);
|
2023-03-18 14:44:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
if (this.timer) {
|
|
|
|
clearInterval(this.timer);
|
|
|
|
this.timer = null;
|
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-06-02 03:54:16 +02:00
|
|
|
async init() {
|
2023-08-25 06:15:03 +02:00
|
|
|
this.enabled = await this.configCore.hasFeature(FeatureFlag.SEARCH);
|
2023-03-03 03:47:08 +01:00
|
|
|
if (!this.enabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.logger.log('Running bootstrap');
|
|
|
|
await this.searchRepository.setup();
|
|
|
|
|
|
|
|
const migrationStatus = await this.searchRepository.checkMigrationStatus();
|
|
|
|
if (migrationStatus[SearchCollection.ASSETS]) {
|
|
|
|
this.logger.debug('Queueing job to re-index all assets');
|
|
|
|
await this.jobRepository.queue({ name: JobName.SEARCH_INDEX_ASSETS });
|
|
|
|
}
|
|
|
|
if (migrationStatus[SearchCollection.ALBUMS]) {
|
|
|
|
this.logger.debug('Queueing job to re-index all albums');
|
|
|
|
await this.jobRepository.queue({ name: JobName.SEARCH_INDEX_ALBUMS });
|
|
|
|
}
|
2023-05-17 19:07:17 +02:00
|
|
|
if (migrationStatus[SearchCollection.FACES]) {
|
|
|
|
this.logger.debug('Queueing job to re-index all faces');
|
|
|
|
await this.jobRepository.queue({ name: JobName.SEARCH_INDEX_FACES });
|
|
|
|
}
|
2023-08-25 06:15:03 +02:00
|
|
|
|
|
|
|
this.timer = setInterval(() => this.flush(), 5_000);
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-05-28 03:56:17 +02:00
|
|
|
async getExploreData(authUser: AuthUserDto): Promise<SearchExploreItem<AssetResponseDto>[]> {
|
2023-08-25 06:15:03 +02:00
|
|
|
await this.configCore.requireFeature(FeatureFlag.SEARCH);
|
|
|
|
|
2023-05-28 03:56:17 +02:00
|
|
|
const results = await this.searchRepository.explore(authUser.id);
|
2023-05-30 19:55:06 +02:00
|
|
|
const lookup = await this.getLookupMap(
|
|
|
|
results.reduce(
|
|
|
|
(ids: string[], result: SearchExploreItem<AssetEntity>) => [
|
|
|
|
...ids,
|
|
|
|
...result.items.map((item) => item.data.id),
|
|
|
|
],
|
|
|
|
[],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2023-05-28 03:56:17 +02:00
|
|
|
return results.map(({ fieldName, items }) => ({
|
|
|
|
fieldName,
|
2023-05-30 19:55:06 +02:00
|
|
|
items: items
|
|
|
|
.map(({ value, data }) => ({ value, data: lookup[data.id] }))
|
|
|
|
.filter(({ data }) => !!data)
|
|
|
|
.map(({ value, data }) => ({ value, data: mapAsset(data) })),
|
2023-05-28 03:56:17 +02:00
|
|
|
}));
|
2023-03-05 21:44:31 +01:00
|
|
|
}
|
|
|
|
|
2023-03-03 03:47:08 +01:00
|
|
|
async search(authUser: AuthUserDto, dto: SearchDto): Promise<SearchResponseDto> {
|
2023-08-25 06:15:03 +02:00
|
|
|
const { machineLearning } = await this.configCore.getConfig();
|
|
|
|
await this.configCore.requireFeature(FeatureFlag.SEARCH);
|
2023-03-03 03:47:08 +01:00
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
const query = dto.q || dto.query || '*';
|
2023-08-29 15:58:00 +02:00
|
|
|
const hasClip = machineLearning.enabled && machineLearning.clip.enabled;
|
2023-08-25 06:15:03 +02:00
|
|
|
const strategy = dto.clip && hasClip ? SearchStrategy.CLIP : SearchStrategy.TEXT;
|
2023-03-18 14:44:42 +01:00
|
|
|
const filters = { userId: authUser.id, ...dto };
|
|
|
|
|
|
|
|
let assets: SearchResult<AssetEntity>;
|
|
|
|
switch (strategy) {
|
|
|
|
case SearchStrategy.CLIP:
|
2023-08-29 15:58:00 +02:00
|
|
|
const {
|
|
|
|
machineLearning: { clip },
|
|
|
|
} = await this.configCore.getConfig();
|
|
|
|
const embedding = await this.machineLearning.encodeText(machineLearning.url, { text: query }, clip);
|
|
|
|
assets = await this.searchRepository.vectorSearch(embedding, filters);
|
2023-03-19 14:20:23 +01:00
|
|
|
break;
|
2023-03-18 22:30:48 +01:00
|
|
|
case SearchStrategy.TEXT:
|
|
|
|
default:
|
|
|
|
assets = await this.searchRepository.searchAssets(query, filters);
|
|
|
|
break;
|
2023-03-18 14:44:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const albums = await this.searchRepository.searchAlbums(query, filters);
|
2023-05-30 19:55:06 +02:00
|
|
|
const lookup = await this.getLookupMap(assets.items.map((asset) => asset.id));
|
2023-03-03 03:47:08 +01:00
|
|
|
|
|
|
|
return {
|
2023-08-11 18:00:51 +02:00
|
|
|
albums: { ...albums, items: albums.items.map(mapAlbumWithAssets) },
|
2023-05-30 19:55:06 +02:00
|
|
|
assets: {
|
|
|
|
...assets,
|
|
|
|
items: assets.items
|
|
|
|
.map((item) => lookup[item.id])
|
|
|
|
.filter((item) => !!item)
|
|
|
|
.map(mapAsset),
|
|
|
|
},
|
2023-03-03 03:47:08 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
async handleIndexAlbums() {
|
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-03-18 14:44:42 +01:00
|
|
|
}
|
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
const albums = this.patchAlbums(await this.albumRepository.getAll());
|
|
|
|
this.logger.log(`Indexing ${albums.length} albums`);
|
|
|
|
await this.searchRepository.importAlbums(albums, true);
|
|
|
|
|
|
|
|
return true;
|
2023-03-18 14:44:42 +01:00
|
|
|
}
|
|
|
|
|
2023-03-03 03:47:08 +01:00
|
|
|
async handleIndexAssets() {
|
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
// TODO: do this in batches based on searchIndexVersion
|
|
|
|
const assetPagination = usePagination(JOBS_ASSET_PAGINATION_SIZE, (pagination) =>
|
|
|
|
this.assetRepository.getAll(pagination, { isVisible: true }),
|
|
|
|
);
|
2023-03-20 21:16:32 +01:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
for await (const assets of assetPagination) {
|
|
|
|
this.logger.debug(`Indexing ${assets.length} assets`);
|
2023-05-22 20:05:06 +02:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
const patchedAssets = this.patchAssets(assets);
|
|
|
|
await this.searchRepository.importAssets(patchedAssets, false);
|
|
|
|
}
|
2023-03-20 21:16:32 +01:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
await this.searchRepository.importAssets([], true);
|
2023-03-22 06:36:32 +01:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
this.logger.debug('Finished re-indexing all assets');
|
|
|
|
|
|
|
|
return false;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:07:17 +02:00
|
|
|
async handleIndexFaces() {
|
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-05-17 19:07:17 +02:00
|
|
|
}
|
2023-07-22 21:42:12 +02:00
|
|
|
await this.searchRepository.deleteAllFaces();
|
2023-05-17 19:07:17 +02:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
// TODO: do this in batches based on searchIndexVersion
|
2023-09-27 22:46:46 +02:00
|
|
|
const faces = this.patchFaces(await this.personRepository.getAllFaces());
|
2023-05-26 21:43:24 +02:00
|
|
|
this.logger.log(`Indexing ${faces.length} faces`);
|
|
|
|
|
|
|
|
const chunkSize = 1000;
|
|
|
|
for (let i = 0; i < faces.length; i += chunkSize) {
|
|
|
|
await this.searchRepository.importFaces(faces.slice(i, i + chunkSize), false);
|
|
|
|
}
|
2023-05-17 19:07:17 +02:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
await this.searchRepository.importFaces([], true);
|
2023-05-17 19:07:17 +02:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
this.logger.debug('Finished re-indexing all faces');
|
2023-05-17 19:07:17 +02:00
|
|
|
|
2023-05-26 21:43:24 +02:00
|
|
|
return true;
|
2023-05-17 19:07:17 +02:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
handleIndexAlbum({ ids }: IBulkEntityJob) {
|
2023-03-03 03:47:08 +01:00
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
for (const id of ids) {
|
|
|
|
this.albumQueue.upsert.add(id);
|
|
|
|
}
|
2023-05-26 21:43:24 +02:00
|
|
|
|
|
|
|
return true;
|
2023-03-18 14:44:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleIndexAsset({ ids }: IBulkEntityJob) {
|
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-03-05 21:44:31 +01:00
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
for (const id of ids) {
|
|
|
|
this.assetQueue.upsert.add(id);
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
2023-05-26 21:43:24 +02:00
|
|
|
|
|
|
|
return true;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:07:17 +02:00
|
|
|
async handleIndexFace({ assetId, personId }: IAssetFaceJob) {
|
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-05-17 19:07:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// immediately push to typesense
|
|
|
|
await this.searchRepository.importFaces(await this.idsToFaces([{ assetId, personId }]), false);
|
2023-05-26 21:43:24 +02:00
|
|
|
|
|
|
|
return true;
|
2023-05-17 19:07:17 +02:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
handleRemoveAlbum({ ids }: IBulkEntityJob) {
|
2023-03-03 03:47:08 +01:00
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
for (const id of ids) {
|
|
|
|
this.albumQueue.delete.add(id);
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
2023-05-26 21:43:24 +02:00
|
|
|
|
|
|
|
return true;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
handleRemoveAsset({ ids }: IBulkEntityJob) {
|
2023-03-03 03:47:08 +01:00
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
for (const id of ids) {
|
|
|
|
this.assetQueue.delete.add(id);
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
2023-05-26 21:43:24 +02:00
|
|
|
|
|
|
|
return true;
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:07:17 +02:00
|
|
|
handleRemoveFace({ assetId, personId }: IAssetFaceJob) {
|
|
|
|
if (!this.enabled) {
|
2023-05-26 21:43:24 +02:00
|
|
|
return false;
|
2023-05-17 19:07:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.faceQueue.delete.add(this.asKey({ assetId, personId }));
|
2023-05-26 21:43:24 +02:00
|
|
|
|
|
|
|
return true;
|
2023-05-17 19:07:17 +02:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
private async flush() {
|
|
|
|
if (this.albumQueue.upsert.size > 0) {
|
|
|
|
const ids = [...this.albumQueue.upsert.keys()];
|
|
|
|
const items = await this.idsToAlbums(ids);
|
|
|
|
this.logger.debug(`Flushing ${items.length} album upserts`);
|
|
|
|
await this.searchRepository.importAlbums(items, false);
|
|
|
|
this.albumQueue.upsert.clear();
|
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
if (this.albumQueue.delete.size > 0) {
|
|
|
|
const ids = [...this.albumQueue.delete.keys()];
|
|
|
|
this.logger.debug(`Flushing ${ids.length} album deletes`);
|
|
|
|
await this.searchRepository.deleteAlbums(ids);
|
|
|
|
this.albumQueue.delete.clear();
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
if (this.assetQueue.upsert.size > 0) {
|
|
|
|
const ids = [...this.assetQueue.upsert.keys()];
|
|
|
|
const items = await this.idsToAssets(ids);
|
|
|
|
this.logger.debug(`Flushing ${items.length} asset upserts`);
|
|
|
|
await this.searchRepository.importAssets(items, false);
|
|
|
|
this.assetQueue.upsert.clear();
|
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
if (this.assetQueue.delete.size > 0) {
|
|
|
|
const ids = [...this.assetQueue.delete.keys()];
|
|
|
|
this.logger.debug(`Flushing ${ids.length} asset deletes`);
|
|
|
|
await this.searchRepository.deleteAssets(ids);
|
|
|
|
this.assetQueue.delete.clear();
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
2023-05-17 19:07:17 +02:00
|
|
|
|
|
|
|
if (this.faceQueue.upsert.size > 0) {
|
|
|
|
const ids = [...this.faceQueue.upsert.keys()].map((key) => this.asParts(key));
|
|
|
|
const items = await this.idsToFaces(ids);
|
|
|
|
this.logger.debug(`Flushing ${items.length} face upserts`);
|
|
|
|
await this.searchRepository.importFaces(items, false);
|
|
|
|
this.faceQueue.upsert.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.faceQueue.delete.size > 0) {
|
|
|
|
const ids = [...this.faceQueue.delete.keys()];
|
|
|
|
this.logger.debug(`Flushing ${ids.length} face deletes`);
|
|
|
|
await this.searchRepository.deleteFaces(ids);
|
|
|
|
this.faceQueue.delete.clear();
|
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|
2023-03-05 21:44:31 +01:00
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
private async idsToAlbums(ids: string[]): Promise<AlbumEntity[]> {
|
|
|
|
const entities = await this.albumRepository.getByIds(ids);
|
|
|
|
return this.patchAlbums(entities);
|
|
|
|
}
|
|
|
|
|
|
|
|
private async idsToAssets(ids: string[]): Promise<AssetEntity[]> {
|
|
|
|
const entities = await this.assetRepository.getByIds(ids);
|
|
|
|
return this.patchAssets(entities.filter((entity) => entity.isVisible));
|
|
|
|
}
|
|
|
|
|
2023-05-17 19:07:17 +02:00
|
|
|
private async idsToFaces(ids: AssetFaceId[]): Promise<OwnedFaceEntity[]> {
|
2023-09-27 22:46:46 +02:00
|
|
|
return this.patchFaces(await this.personRepository.getFacesByIds(ids));
|
2023-05-17 19:07:17 +02:00
|
|
|
}
|
|
|
|
|
2023-03-18 14:44:42 +01:00
|
|
|
private patchAssets(assets: AssetEntity[]): AssetEntity[] {
|
|
|
|
return assets;
|
|
|
|
}
|
|
|
|
|
|
|
|
private patchAlbums(albums: AlbumEntity[]): AlbumEntity[] {
|
|
|
|
return albums.map((entity) => ({ ...entity, assets: [] }));
|
|
|
|
}
|
2023-05-17 19:07:17 +02:00
|
|
|
|
|
|
|
private patchFaces(faces: AssetFaceEntity[]): OwnedFaceEntity[] {
|
|
|
|
return faces.map((face) => ({
|
|
|
|
id: this.asKey(face),
|
|
|
|
ownerId: face.asset.ownerId,
|
|
|
|
assetId: face.assetId,
|
|
|
|
personId: face.personId,
|
|
|
|
embedding: face.embedding,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
private asKey(face: AssetFaceId): string {
|
|
|
|
return `${face.assetId}|${face.personId}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
private asParts(key: string): AssetFaceId {
|
|
|
|
const [assetId, personId] = key.split('|');
|
|
|
|
return { assetId, personId };
|
|
|
|
}
|
2023-05-30 19:55:06 +02:00
|
|
|
|
|
|
|
private async getLookupMap(assetIds: string[]) {
|
|
|
|
const assets = await this.assetRepository.getByIds(assetIds);
|
|
|
|
const lookup: Record<string, AssetEntity> = {};
|
|
|
|
for (const asset of assets) {
|
|
|
|
lookup[asset.id] = asset;
|
|
|
|
}
|
|
|
|
return lookup;
|
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|