Skip to content
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

FIX: Don't count the current user in "Others with this badge." #6016

Merged
merged 1 commit into from
Jul 2, 2018

Conversation

misaka4e21
Copy link
Contributor

@discoursebot
Copy link

You've signed the CLA, misaka4e21. Thank you! This pull request is ready for review.

@@ -25,7 +25,7 @@ export default Ember.Controller.extend(BadgeSelectController, {

@computed("username", "model.grant_count", "userBadges.grant_count")
grantCount(username, modelCount, userCount) {
return username ? userCount : modelCount;
return username ? userCount : modelCount - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm how do we know if the user hass been granted that badge or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new computed variable othersCount to exclude the current user. It will be shown only if canShowOthers is true.

@@ -28,6 +28,11 @@ export default Ember.Controller.extend(BadgeSelectController, {
return username ? userCount : modelCount;
},

@computed("model.grant_count")
othersCount(grant_count) {
return grant_count - 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is not going to be a simple -1, you could have multiple badges of the type, so you need to subtract the number you have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.
Should I consider that other people can also have multiple badges per person?

Don't count the current user in "Others with this badge".
@tgxworld tgxworld merged commit cb86c5a into discourse:master Jul 2, 2018
@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/count-at-others-with-this-badge-includes-current-user/90089/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants