fix: apply feedback updates

This commit is contained in:
yassinedorbozgithub 2025-04-03 08:17:43 +01:00
parent 1eb09ab84e
commit 1cc99d0020
2 changed files with 22 additions and 15 deletions

View File

@ -117,24 +117,15 @@ export class NlpValueRepository extends BaseRepository<
}
private async aggregateWithCount<T extends 'full' | 'stub' = 'stub'>(
{ limit = 10, skip = 0, sort = ['createdAt', -1] }: PageQueryDto<NlpValue>,
{
limit = 10,
skip = 0,
sort = ['createdAt', 'desc'],
}: PageQueryDto<NlpValue>,
{ $and = [], ...rest }: TFilterQuery<NlpValue>,
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<TNlpValueCountFormat<T>>(pipeline).exec();

View File

@ -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 }) => (
<Chip
sx={{ alignContent: "center" }}
id={(row.nlpSamplesCount || `nlpSamplesCount_${row.id}`).toString()}
label={row.nlpSamplesCount?.toString()}
variant="inbox"