Skip to content

Commit 07e16d1

Browse files
committed
fix: sorting
1 parent 8989bbe commit 07e16d1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/routes/copilotRequest/list.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ module.exports = [
3636
'opportunityTitle desc',
3737
'projectType asc',
3838
'projectType desc',
39+
'status asc',
40+
'status desc',
3941
];
4042
if (_.indexOf(sortableProps, sort) < 0) {
4143
return util.handleError('Invalid sort criteria', null, req, next);
@@ -45,11 +47,17 @@ module.exports = [
4547
const relationBasedSortParams = ['projectName'];
4648
const jsonBasedSortParams = ['opportunityTitle', 'projectType'];
4749
if (relationBasedSortParams.includes(sortParams[0])) {
48-
order = [[{model: models.Project, as: 'project'}, 'name', sortParams[1]]]
50+
order = [
51+
[{model: models.Project, as: 'project'}, 'name', sortParams[1]],
52+
['id', 'DESC']
53+
]
4954
}
5055

5156
if (jsonBasedSortParams.includes(sortParams[0])) {
52-
order = [[models.sequelize.literal(`("CopilotRequest"."data"->>'${sortParams[0]}')`), sortParams[1]]]
57+
order = [
58+
[models.sequelize.literal(`("CopilotRequest"."data"->>'${sortParams[0]}')`), sortParams[1]],
59+
['id', 'DESC'],
60+
]
5361
}
5462

5563
const whereCondition = projectId ? { projectId } : {};

0 commit comments

Comments
 (0)