mirror of
https://github.com/immich-app/immich.git
synced 2026-03-01 18:19:10 +03:00
feat: use stream for template migrations (#16700)
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
} from 'src/entities/asset.entity';
|
||||
import { AssetFileType, AssetOrder, AssetStatus, AssetType } from 'src/enum';
|
||||
import { AssetSearchOptions, SearchExploreItem, SearchExploreItemSet } from 'src/repositories/search.repository';
|
||||
import { StorageAsset } from 'src/types';
|
||||
import { anyUuid, asUuid, removeUndefinedKeys, unnest } from 'src/utils/database';
|
||||
import { globToSqlPattern } from 'src/utils/misc';
|
||||
import { Paginated, PaginationOptions, paginationHelper } from 'src/utils/pagination';
|
||||
@@ -604,6 +605,38 @@ export class AssetRepository {
|
||||
.executeTakeFirst() as Promise<AssetEntity | undefined>;
|
||||
}
|
||||
|
||||
private storageTemplateAssetQuery() {
|
||||
return this.db
|
||||
.selectFrom('assets')
|
||||
.innerJoin('exif', 'assets.id', 'exif.assetId')
|
||||
.select([
|
||||
'assets.id',
|
||||
'assets.ownerId',
|
||||
'assets.type',
|
||||
'assets.checksum',
|
||||
'assets.originalPath',
|
||||
'assets.isExternal',
|
||||
'assets.sidecarPath',
|
||||
'assets.originalFileName',
|
||||
'assets.livePhotoVideoId',
|
||||
'assets.fileCreatedAt',
|
||||
'exif.timeZone',
|
||||
'exif.fileSizeInByte',
|
||||
])
|
||||
.where('assets.deletedAt', 'is', null)
|
||||
.where('assets.fileCreatedAt', 'is not', null);
|
||||
}
|
||||
|
||||
getStorageTemplateAsset(id: string): Promise<StorageAsset | undefined> {
|
||||
return this.storageTemplateAssetQuery().where('assets.id', '=', id).executeTakeFirst() as Promise<
|
||||
StorageAsset | undefined
|
||||
>;
|
||||
}
|
||||
|
||||
streamStorageTemplateAssets() {
|
||||
return this.storageTemplateAssetQuery().stream() as AsyncIterableIterator<StorageAsset>;
|
||||
}
|
||||
|
||||
@GenerateSql(
|
||||
...Object.values(WithProperty).map((property) => ({
|
||||
name: property,
|
||||
|
||||
Reference in New Issue
Block a user