Skip to content

Commit

Permalink
fix(server): fix inconsistent explore queries (immich-app#5774)
Browse files Browse the repository at this point in the history
* remove limits

* update sql
  • Loading branch information
mertalev authored Dec 17, 2023
1 parent 08f66c2 commit e3fa32a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
8 changes: 2 additions & 6 deletions server/src/infra/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,7 @@ export class AssetRepository implements IAssetRepository {
.createQueryBuilder('e')
.select('city')
.groupBy('city')
.having('count(city) >= :minAssetsPerField', { minAssetsPerField })
.orderBy('random()')
.limit(maxFields);
.having('count(city) >= :minAssetsPerField', { minAssetsPerField });

const items = await this.getBuilder({
userIds: [ownerId],
Expand Down Expand Up @@ -737,9 +735,7 @@ export class AssetRepository implements IAssetRepository {
.createQueryBuilder('si')
.select('unnest(tags)', 'tag')
.groupBy('tag')
.having('count(*) >= :minAssetsPerField', { minAssetsPerField })
.orderBy('random()')
.limit(maxFields);
.having('count(*) >= :minAssetsPerField', { minAssetsPerField });

const items = await this.getBuilder({
userIds: [ownerId],
Expand Down
8 changes: 0 additions & 8 deletions server/src/infra/sql/asset.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,6 @@ WITH
city
HAVING
count(city) >= $1
ORDER BY
random() ASC
LIMIT
12
)
SELECT DISTINCT
ON (c.city) "asset"."id" AS "data",
Expand Down Expand Up @@ -653,10 +649,6 @@ WITH
tag
HAVING
count(*) >= $1
ORDER BY
random() ASC
LIMIT
12
)
SELECT DISTINCT
ON (unnest("si"."tags")) "asset"."id" AS "data",
Expand Down

0 comments on commit e3fa32a

Please sign in to comment.