Skip to content

Commit

Permalink
Remove sorting by assignees in Issue Sorter (#286)
Browse files Browse the repository at this point in the history
Co-authored-by: Misra Aditya <[email protected]>
  • Loading branch information
MadLamprey and Misra Aditya authored Mar 12, 2024
1 parent f6a8f23 commit 7e68bbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
22 changes: 9 additions & 13 deletions src/app/shared/issue-tables/issue-sorter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ export function applySort(sort: Sort, data: Issue[]): Issue[] {

const direction: number = sort.direction === 'asc' ? 1 : -1;

return data.sort((a, b) => {
switch (sort.active) {
case 'assignees':
return direction * compareByStringValue(a.assignees.join(', '), b.assignees.join(', '));
case 'id':
return direction * compareByIntegerValue(a.id, b.id);
case 'date':
return direction * compareByDateValue(a.updated_at, b.updated_at);
default:
// title, responseTag are string values
return direction * compareByStringValue(a[sort.active], b[sort.active]);
}
});
switch (sort.active) {
case 'id':
return data.sort((a, b) => direction * compareByIntegerValue(a.id, b.id));
case 'date':
return data.sort((a, b) => direction * compareByDateValue(a.updated_at, b.updated_at));
default:
// title, responseTag are string values
return data.sort((a, b) => direction * compareByStringValue(a[sort.active], b[sort.active]));
}
}

function compareByStringValue(valueA: string, valueB: string): number {
Expand Down
11 changes: 0 additions & 11 deletions tests/app/shared/issue-tables/issue-sorter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ describe('issuer-sorter', () => {
expect(sortedData).toEqual(issuesList);
});

it('sorts issues based on their assignees correctly', () => {
matSort.active = 'assignees';
matSort.direction = 'asc';
const sortedIssuesByAssigneesAsc = applySort(matSort, issuesList);
assertOrder(sortedIssuesByAssigneesAsc, dummyIssue, otherDummyIssue);

matSort.direction = 'desc';
const sortedIssuesByAssigneesDesc = applySort(matSort, issuesList);
assertOrder(sortedIssuesByAssigneesDesc, otherDummyIssue, dummyIssue);
});

it('sorts issues based on their string fields correctly', () => {
matSort.active = 'title';
matSort.direction = 'asc';
Expand Down

0 comments on commit 7e68bbd

Please sign in to comment.