Skip to content

Commit

Permalink
[#463] ChartView: add contribution and variance to sort groups by (#…
Browse files Browse the repository at this point in the history
…639)

Contribution and variance options are not available in `sort groups by`
when the `group by` option is selected.

Users may wish to sort the groups with this 2 options, ranking them in
terms of activity level, so that they can pay more attention to the
most/least achievers.

Let's allow the sorting of groups, by these 2 options, be available at
all times.
  • Loading branch information
chel-seyy authored and eugenepeh committed May 4, 2019
1 parent b64711d commit 81db2aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 2 additions & 0 deletions frontend/cypress/tests/codeView_toolBar_searchBox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
describe('search bar', () => {
it('non-existent author shows no result', () => {
cy.get('#tabs-wrapper .tab-close').click();
cy.get('#summary-wrapper input[type=text]')
.type('abcdef')
.type('{enter}');
Expand All @@ -21,6 +22,7 @@ describe('search bar', () => {
});

it('unique author shows one result', () => {
cy.get('#tabs-wrapper .tab-close').click();
cy.get('#summary-wrapper input[type=text]')
.type('Yong Hao TENG')
.type('{enter}');
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ html
option(value="name dsc", v-if="filterGroupSelection !== 'groupByRepos'") ↓ name
option(value="searchPath", v-if="filterGroupSelection !== 'groupByAuthors'") ↑ repo/branch
option(value="searchPath dsc", v-if="filterGroupSelection !== 'groupByAuthors'") ↓ repo/branch
option(value="totalCommits", v-if="filterGroupSelection === 'groupByNone'") ↑ contribution
option(value="totalCommits dsc", v-if="filterGroupSelection === 'groupByNone'") ↓ contribution
option(value="variance", v-if="filterGroupSelection === 'groupByNone'") ↑ variance
option(value="variance dsc", v-if="filterGroupSelection === 'groupByNone'") ↓ variance
option(value="totalCommits") ↑ contribution
option(value="totalCommits dsc") ↓ contribution
option(value="variance") ↑ variance
option(value="variance dsc") ↓ variance
label sort groups by
.mui-select.sort-within-group
select(v-model="sortWithinGroupSelection")
Expand Down
22 changes: 18 additions & 4 deletions frontend/src/static/js/v_summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,14 @@ window.vSummary = {
if (!this.sortWithinGroupSelection || this.sortingWithinOption === 'name') {
this.sortWithinGroupSelection = 'searchPath';
}
if (this.sortingOption !== 'name') {
if (this.sortingOption === 'searchPath') {
this.sortGroupSelection = 'name';
}
} else if (this.filterGroupSelection === 'groupByRepos') {
if (!this.sortWithinGroupSelection || this.sortingWithinOption === 'searchPath') {
this.sortWithinGroupSelection = 'name';
}
if (this.sortingOption !== 'searchPath') {
if (this.sortingOption === 'name') {
this.sortGroupSelection = 'searchPath';
}
} else if (this.filterGroupSelection === 'groupByNone') {
Expand Down Expand Up @@ -483,7 +483,12 @@ window.vSummary = {
}
sortedRepos.push(users);
});
sortedRepos.sort(window.comparator((repo) => repo[0][this.sortingOption]));
sortedRepos.sort(window.comparator((repo) => {
if (this.sortingOption === 'totalCommits' || this.sortingOption === 'variance') {
return repo.reduce(this.getGroupCommitsVariance, 0);
}
return repo[0][this.sortingOption];
}));
if (this.isSortingDsc) {
sortedRepos.reverse();
}
Expand Down Expand Up @@ -523,12 +528,21 @@ window.vSummary = {
filtered.push(authorMap[author]);
});

filtered.sort(window.comparator((ele) => ele[0][this.sortingOption]));
filtered.sort(window.comparator((author) => {
if (this.sortingOption === 'totalCommits' || this.sortingOption === 'variance') {
return author.reduce(this.getGroupCommitsVariance, 0);
}
return author[0][this.sortingOption];
}));
if (this.isSortingDsc) {
filtered.reverse();
}
return filtered;
},

getGroupCommitsVariance(total, group) {
return total + group[this.sortingOption];
},
},
created() {
this.renderFilterHash();
Expand Down

0 comments on commit 81db2aa

Please sign in to comment.