Skip to content

Commit b8343b9

Browse files
committed
fix: added sorting functionality
1 parent c958c3c commit b8343b9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/routes/copilotRequest/list.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ module.exports = [
3131
if (_.indexOf(sortableProps, sort) < 0) {
3232
return util.handleError('Invalid sort criteria', null, req, next);
3333
}
34-
const sortParams = sort.split(' ');
34+
let sortParams = sort.split(' ');
35+
let order = [[sortParams[0], sortParams[1]]]
36+
if (sortParams[0] === 'projectName') {
37+
order = [[{model: models.Project, as: 'project'}, 'name', sortParams[1]]]
38+
}
3539

3640
const whereCondition = projectId ? { projectId } : {};
3741

@@ -41,7 +45,7 @@ module.exports = [
4145
{ model: models.CopilotOpportunity, as: 'copilotOpportunity', required: false },
4246
{ model: models.Project, as: 'project', required: false },
4347
],
44-
order: [[sortParams[0], sortParams[1]]],
48+
order,
4549
limit: pageSize,
4650
offset,
4751
distinct: true,

0 commit comments

Comments
 (0)