From 7c47a38cc1680cc9dc755eaabcd3d0633151ea65 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Tue, 24 Jan 2023 11:25:57 +0100 Subject: [PATCH] catalog: improve sort fields namings Signed-off-by: Vincenzo Scamporlino --- .../src/service/DefaultEntitiesCatalog.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts index bf5c7f8242..53e30e663e 100644 --- a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts +++ b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts @@ -356,8 +356,7 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog { ...cursor.sortFields[0], }; - const [sortFieldValue, metadataSortFieldValue] = - cursor.sortFieldValues || []; + const [prevItemSortFieldValue, prevItemUid] = cursor.sortFieldValues || []; const dbQuery = db('search') .join('final_entities', 'search.entity_id', 'final_entities.entity_id') @@ -379,17 +378,17 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog { const isOrderingDescending = sortField.order === 'desc'; - if (sortFieldValue) { + if (prevItemSortFieldValue) { dbQuery.andWhere( 'value', isFetchingBackwards !== isOrderingDescending ? '<' : '>', - sortFieldValue, + prevItemSortFieldValue, ); dbQuery.orWhere(function nested() { - this.where('value', '=', sortFieldValue).andWhere( + this.where('value', '=', prevItemSortFieldValue).andWhere( 'search.entity_id', isFetchingBackwards !== isOrderingDescending ? '<' : '>', - metadataSortFieldValue, + prevItemUid, ); }); }