Skip to content

Commit

Permalink
[#1917] Commits view: sort everything in reverse chronological order (#…
Browse files Browse the repository at this point in the history
…2024)

Currently days are sorted in reverse chronological order while commits 
are sorted in chronological order.

Sorting days and commits in the same chronological order seems 
more intuitive.

Let's implement changes such that days and commits are sorted in 
the same chronological order. Sorting by LoC also sorts the commits 
of the day by LoC.
  • Loading branch information
pratham31012002 committed Aug 7, 2023
1 parent 3cf77b4 commit b25d1fe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frontend/cypress/tests/zoomView/zoomView_diffstat.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('diffstat', () => {
.click();

cy.get('#tab-zoom .commit-message')
.first()
.eq(1)
.within(() => {
cy.get('.stacked-bar__contrib--bar')
.then((element) => {
Expand All @@ -40,7 +40,7 @@ describe('diffstat', () => {
.click();

cy.get('#tab-zoom .commit-message')
.eq(1)
.first()
.within(() => {
cy.get('.stacked-bar__contrib--bar')
.then((element) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ describe('hide all commit messages ', () => {

// commit body of the merge commit should be visible
cy.get('#tab-zoom .commit-message .body')
.eq(1)
.eq(0)
.should('be.visible');

// commit body of the md commit should not be visible
cy.get('#tab-zoom .commit-message .body')
.eq(0)
.eq(1)
.should('not.be.visible');

// commit body of the java commit should be visible
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/views/c-zoom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,24 @@ export default defineComponent({
).sort(this.sortingFunction);
}
return new User(filteredUser);
const tempUser: User = { ...filteredUser };
tempUser.commits = [];
filteredUser.commits.forEach((commit) => {
const newCommit = { ...commit };
newCommit.commitResults = [];
if (this.commitsSortType === CommitsSortType.Time) {
newCommit.commitResults = this.toReverseSortedCommits
? commit.commitResults.slice().reverse()
: commit.commitResults.slice();
} else {
const cResultsSortingFunction = (a: CommitResult, b: CommitResult) => (this.toReverseSortedCommits ? -1 : 1)
* window.comparator((cResult: CommitResult) => cResult.insertions)(a, b);
newCommit.commitResults = commit.commitResults.slice().sort(cResultsSortingFunction);
}
tempUser.commits.push(newCommit);
});
return new User(tempUser);
},
selectedCommits(): Commit[] {
Expand Down

0 comments on commit b25d1fe

Please sign in to comment.