From 1cc99d00206dd08c12303fe28fe181cb98d2f26e Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 3 Apr 2025 08:17:43 +0100 Subject: [PATCH] fix: apply feedback updates --- .../nlp/repositories/nlp-value.repository.ts | 32 +++++++++++-------- .../components/nlp/components/NlpValue.tsx | 5 ++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/api/src/nlp/repositories/nlp-value.repository.ts b/api/src/nlp/repositories/nlp-value.repository.ts index b6a5eec8..73236796 100644 --- a/api/src/nlp/repositories/nlp-value.repository.ts +++ b/api/src/nlp/repositories/nlp-value.repository.ts @@ -117,24 +117,15 @@ export class NlpValueRepository extends BaseRepository< } private async aggregateWithCount( - { limit = 10, skip = 0, sort = ['createdAt', -1] }: PageQueryDto, + { + limit = 10, + skip = 0, + sort = ['createdAt', 'desc'], + }: PageQueryDto, { $and = [], ...rest }: TFilterQuery, populatePipelineStages: PipelineStage[] = [], ) { const pipeline: PipelineStage[] = [ - // support pageQuery - { - $limit: limit, - }, - { - $skip: skip, - }, - { - $sort: { - [sort[0]]: sort[1] === 'desc' ? -1 : 1, - _id: sort[1] === 'desc' ? -1 : 1, - }, - }, { // support filters $match: { @@ -152,6 +143,13 @@ export class NlpValueRepository extends BaseRepository< }), }, }, + // support pageQuery + { + $skip: skip, + }, + { + $limit: limit, + }, { $lookup: { from: 'nlpsampleentities', @@ -196,6 +194,12 @@ export class NlpValueRepository extends BaseRepository< }, }, ...populatePipelineStages, + { + $sort: { + [sort[0]]: sort[1].toString().startsWith('desc') ? -1 : 1, + _id: sort[1].toString().startsWith('desc') ? -1 : 1, + }, + }, ]; return await this.model.aggregate>(pipeline).exec(); diff --git a/frontend/src/components/nlp/components/NlpValue.tsx b/frontend/src/components/nlp/components/NlpValue.tsx index 92cc7d04..c0a6b18d 100644 --- a/frontend/src/components/nlp/components/NlpValue.tsx +++ b/frontend/src/components/nlp/components/NlpValue.tsx @@ -126,14 +126,17 @@ export const NlpValues = ({ entityId }: { entityId: string }) => { renderHeader, }, { - flex: 3, + flex: 2, field: "nlpSamplesCount", + align: "center", headerName: t("label.nlp_samples_count"), sortable: true, disableColumnMenu: true, + headerAlign: "center", renderHeader, renderCell: ({ row }) => (