You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-09 23:17:29 +02:00
fix(server): searchRandom
response (#15580)
* fix searchRandom * add e2e * set outer limit
This commit is contained in:
@@ -60,6 +60,8 @@ union all
|
||||
limit
|
||||
$14
|
||||
)
|
||||
limit
|
||||
$15
|
||||
|
||||
-- SearchRepository.searchSmart
|
||||
select
|
||||
|
@@ -69,12 +69,13 @@ export class SearchRepository implements ISearchRepository {
|
||||
},
|
||||
],
|
||||
})
|
||||
searchRandom(size: number, options: AssetSearchOptions): Promise<AssetEntity[]> {
|
||||
async searchRandom(size: number, options: AssetSearchOptions): Promise<AssetEntity[]> {
|
||||
const uuid = randomUUID();
|
||||
const builder = searchAssetBuilder(this.db, options);
|
||||
const lessThan = builder.where('assets.id', '<', uuid).orderBy('assets.id').limit(size);
|
||||
const greaterThan = builder.where('assets.id', '>', uuid).orderBy('assets.id').limit(size);
|
||||
return sql`${lessThan} union all ${greaterThan}`.execute(this.db) as any as Promise<AssetEntity[]>;
|
||||
const { rows } = await sql`${lessThan} union all ${greaterThan} limit ${size}`.execute(this.db);
|
||||
return rows as any as AssetEntity[];
|
||||
}
|
||||
|
||||
@GenerateSql({
|
||||
|
Reference in New Issue
Block a user