From d1e16025cfeea56ad0d793cafe633690808d5f66 Mon Sep 17 00:00:00 2001 From: Emanuel Bennici Date: Thu, 4 Jan 2024 21:47:09 +0100 Subject: [PATCH] fix(server): Fix incorrect sorting with search (#6031) The search results are not sorted by date causing confision. Fixes #5916 --- server/src/infra/repositories/asset.repository.ts | 1 + server/src/infra/sql/asset.repository.sql | 2 ++ 2 files changed, 3 insertions(+) diff --git a/server/src/infra/repositories/asset.repository.ts b/server/src/infra/repositories/asset.repository.ts index be6c0374ad..31bf554861 100644 --- a/server/src/infra/repositories/asset.repository.ts +++ b/server/src/infra/repositories/asset.repository.ts @@ -828,6 +828,7 @@ export class AssetRepository implements IAssetRepository { @@ PLAINTO_TSQUERY('english', :query)`, { query }, ) + .addOrderBy('asset.fileCreatedAt', 'DESC') .limit(numResults) .getRawMany(); diff --git a/server/src/infra/sql/asset.repository.sql b/server/src/infra/sql/asset.repository.sql index 1c033ccb7d..8dd2cf729d 100644 --- a/server/src/infra/sql/asset.repository.sql +++ b/server/src/infra/sql/asset.repository.sql @@ -841,5 +841,7 @@ WHERE ) @@ PLAINTO_TSQUERY('english', $3) ) AND ("asset"."deletedAt" IS NULL) +ORDER BY + "asset"."fileCreatedAt" DESC LIMIT 250