refactor: move encoded video to asset files table (#26863)

* refactor: move encoded video to asset files table

* chore: update
This commit is contained in:
Brandon Wees
2026-03-12 15:15:21 -05:00
committed by GitHub
parent 990aff441b
commit f3b7cd6198
19 changed files with 158 additions and 60 deletions

View File

@@ -355,7 +355,16 @@ export function searchAssetBuilder(kysely: Kysely<DB>, options: AssetSearchBuild
.$if(!!options.id, (qb) => qb.where('asset.id', '=', asUuid(options.id!)))
.$if(!!options.libraryId, (qb) => qb.where('asset.libraryId', '=', asUuid(options.libraryId!)))
.$if(!!options.userIds, (qb) => qb.where('asset.ownerId', '=', anyUuid(options.userIds!)))
.$if(!!options.encodedVideoPath, (qb) => qb.where('asset.encodedVideoPath', '=', options.encodedVideoPath!))
.$if(!!options.encodedVideoPath, (qb) =>
qb
.innerJoin('asset_file', (join) =>
join
.onRef('asset.id', '=', 'asset_file.assetId')
.on('asset_file.type', '=', AssetFileType.EncodedVideo)
.on('asset_file.isEdited', '=', false),
)
.where('asset_file.path', '=', options.encodedVideoPath!),
)
.$if(!!options.originalPath, (qb) =>
qb.where(sql`f_unaccent(asset."originalPath")`, 'ilike', sql`'%' || f_unaccent(${options.originalPath}) || '%'`),
)
@@ -380,7 +389,15 @@ export function searchAssetBuilder(kysely: Kysely<DB>, options: AssetSearchBuild
.$if(options.isFavorite !== undefined, (qb) => qb.where('asset.isFavorite', '=', options.isFavorite!))
.$if(options.isOffline !== undefined, (qb) => qb.where('asset.isOffline', '=', options.isOffline!))
.$if(options.isEncoded !== undefined, (qb) =>
qb.where('asset.encodedVideoPath', options.isEncoded ? 'is not' : 'is', null),
qb.where((eb) => {
const exists = eb.exists((eb) =>
eb
.selectFrom('asset_file')
.whereRef('assetId', '=', 'asset.id')
.where('type', '=', AssetFileType.EncodedVideo),
);
return options.isEncoded ? exists : eb.not(exists);
}),
)
.$if(options.isMotion !== undefined, (qb) =>
qb.where('asset.livePhotoVideoId', options.isMotion ? 'is not' : 'is', null),