-
Notifications
You must be signed in to change notification settings - Fork 154
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
[#1959] Missing contribution bar for merged groups after refresh #1960
[#1959] Missing contribution bar for merged groups after refresh #1960
Conversation
Hi @MarcusTXK, this is a great catch, and thanks for taking up the issue! |
if (totalCount === 0) { | ||
return 0; | ||
} |
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.
Interestingly, this is what is causing the cypress test to fail. By adding this guard clause, the browser hangs if you check "breakdown by file type", uncheck "All" and then try to check any one of the file types. There is a part of the frontend that only works when the output is NaN
due to the division of 0.
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 changes LGTM, thanks for catching this! Do you think it will be helpful to add a cypress test case to make sure this functionality doesn't break in the future?
I think that is a great suggestion to help detect such issues in advance in the future. Would it be a good idea to add this as a separate issue? |
Yup I think it will be good to add it as a separate issue, especially since this is a bug fix and not a new feature |
frontend/src/utils/api.ts
Outdated
@@ -269,7 +269,7 @@ window.api = { | |||
searchPath: searchParams.join('_').toLowerCase(), | |||
repoName: `${repo.displayName}`, | |||
location: `${repo.location.location}`, | |||
checkedFileTypeContribution: 0, | |||
checkedFileTypeContribution: -1, |
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 we are using -1
instead of undefined
here as the default value? I feel that undefined
or maybe null
would be more intuitive for developers.
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 initial reason was so I did not want to deal with undefined
, however I do not have a strong opinion on this. Let me update it to undefined
.
@@ -318,7 +322,7 @@ export default { | |||
contributionBars.push(fullBarWidth); | |||
} | |||
const remainingBarWidth = barWidth % fullBarWidth; | |||
if (remainingBarWidth !== 0) { | |||
if (remainingBarWidth >= 0) { |
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.
Should it be a >
or >=
here
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.
Good catch, let me change this.
frontend/src/views/c-summary.vue
Outdated
@@ -201,7 +201,7 @@ export default { | |||
let totalCount = 0; | |||
this.repos.forEach((repo) => { | |||
repo.users.forEach((user) => { | |||
if (user.checkedFileTypeContribution === undefined) { | |||
if (user.checkedFileTypeContribution === -1) { |
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.
I also think it might be more appropriate to replace -1
with values such as undefined
as default. Can you take a look again
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.
LGTM. It was a good catch. Just remember to add a test on this to make sure we do not repeat the same bug in future.
@MarcusTXK Are you able to resolve the issues with the |
The following links are for previewing this pull request:
|
Fixes #1959
Proposed commit message
Other information
This was likely introduced in PR #1903 when the initial value of
checkedFileTypeContribution
was refactored to be set as0
, when it was previously expected to beundefined
. This resulted inthis.updateCheckedFileTypeContribution(user)
not being called when the page was refreshed, and resulted in bothtotalLines
andtotalCount
to be 0. There were no guard clauses for division of 0 which resulted inNaN
being returned foravgContributionSize()
, causingcnt
to beNaN
as well when it was divided bycontributionLimit
.