-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1420] Extract some code from summary.js #1421
[#1420] Extract some code from summary.js #1421
Conversation
function getTotalCommits(total, group) { | ||
return total + group.checkedFileTypeContribution; | ||
} | ||
|
||
function getGroupCommitsVariance(total, group) { | ||
return total + group.variance; | ||
} | ||
|
||
// function getGroupCommitsVariance(sortingOption) { | ||
// return function (total, group) { | ||
// if (sortingOption === 'totalCommits') { | ||
// return total + group.checkedFileTypeContribution; | ||
// } | ||
// return total + group[sortingOption]; | ||
// }; | ||
// } | ||
|
||
function sortingHelper(element, sortingOption) { | ||
// return sortingOption === 'totalCommits' || sortingOption === 'variance' | ||
// ? element.reduce(getGroupCommitsVariance, 0) | ||
// : element[0][sortingOption]; | ||
if (sortingOption === 'totalCommits') { | ||
return element.reduce(getTotalCommits, 0); | ||
} | ||
if (sortingOption === 'variance') { | ||
return element.reduce(getGroupCommitsVariance, 0); | ||
} | ||
return element[0][sortingOption]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change I made to the code. Will remove comments once verified is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for making this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I realized that the commented code was not the original code sorry.
The reason why I changed the original code is because it was using this.sortingOption
which is not available when extracted, and that returning an anonymous function is not the best idea (I think there was a warning).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few initial comments.
function getTotalCommits(total, group) { | ||
return total + group.checkedFileTypeContribution; | ||
} | ||
|
||
function getGroupCommitsVariance(total, group) { | ||
return total + group.variance; | ||
} | ||
|
||
// function getGroupCommitsVariance(sortingOption) { | ||
// return function (total, group) { | ||
// if (sortingOption === 'totalCommits') { | ||
// return total + group.checkedFileTypeContribution; | ||
// } | ||
// return total + group[sortingOption]; | ||
// }; | ||
// } | ||
|
||
function sortingHelper(element, sortingOption) { | ||
// return sortingOption === 'totalCommits' || sortingOption === 'variance' | ||
// ? element.reduce(getGroupCommitsVariance, 0) | ||
// : element[0][sortingOption]; | ||
if (sortingOption === 'totalCommits') { | ||
return element.reduce(getTotalCommits, 0); | ||
} | ||
if (sortingOption === 'variance') { | ||
return element.reduce(getGroupCommitsVariance, 0); | ||
} | ||
return element[0][sortingOption]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for making this change?
@gerhean Pls answer the questions and proceed with PR. |
Would it be good to merge this first and extract more stuff in another PR? |
What are the other changes you plan to extract? Can you give some line number? |
function getTotalCommits(total, group) { | ||
return total + group.checkedFileTypeContribution; | ||
} | ||
|
||
function getGroupCommitsVariance(total, group) { | ||
return total + group.variance; | ||
} | ||
|
||
// function getGroupCommitsVariance(total, group) { | ||
// if (this.sortingOption === 'totalCommits') { | ||
// return total + group.checkedFileTypeContribution; | ||
// } | ||
// return total + group[this.sortingOption]; | ||
// } | ||
|
||
function sortingHelper(element, sortingOption) { | ||
// return sortingOption === 'totalCommits' || sortingOption === 'variance' | ||
// ? element.reduce(getGroupCommitsVariance, 0) | ||
// : element[0][sortingOption]; | ||
if (sortingOption === 'totalCommits') { | ||
return element.reduce(getTotalCommits, 0); | ||
} | ||
if (sortingOption === 'variance') { | ||
return element.reduce(getGroupCommitsVariance, 0); | ||
} | ||
return element[0][sortingOption]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I realized that the previously commented code was not the original code sorry.
The reason why I changed the original code is because it was using this.sortingOption
which is not available when extracted, and that returning an anonymous function is not the best idea (I think there was a warning).
At the moment I'm not really focusing on this so nothing yet. |
Repositories with more than 19 different types of files will crash, which can be traced from line 448 of `v_summary.js`. Bug is caused by a function not being copied properly in #1421, leading to an undefined function call. Let's copy the function over properly.
Some of [#1420], but more can certainly be done.