From e3fa32ad230ac76bb24556b47315d0899489709b Mon Sep 17 00:00:00 2001 From: Mert <101130780+mertalev@users.noreply.github.com> Date: Sun, 17 Dec 2023 12:04:35 -0500 Subject: [PATCH] fix(server): fix inconsistent explore queries (#5774) * remove limits * update sql --- server/src/infra/repositories/asset.repository.ts | 8 ++------ server/src/infra/sql/asset.repository.sql | 8 -------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/server/src/infra/repositories/asset.repository.ts b/server/src/infra/repositories/asset.repository.ts index e96aa636f3..e4ba0e2916 100644 --- a/server/src/infra/repositories/asset.repository.ts +++ b/server/src/infra/repositories/asset.repository.ts @@ -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], @@ -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], diff --git a/server/src/infra/sql/asset.repository.sql b/server/src/infra/sql/asset.repository.sql index b268d65522..aab8492d2a 100644 --- a/server/src/infra/sql/asset.repository.sql +++ b/server/src/infra/sql/asset.repository.sql @@ -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", @@ -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",