-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Consistent overriding of labels set by the user #1218
Conversation
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.
Thanks for this!
server.js
Outdated
@@ -3342,7 +3342,7 @@ cache(function(query_data, match, sendBadge, request) { | |||
// falls through | |||
default: | |||
var value = typeof json_data[info] != 'undefined' && typeof json_data[info] != 'object' ? json_data[info] : Array.isArray(json_data[info]) ? json_data[info].join(", ") : 'invalid data'; | |||
badgeData.text[0] = query_data.label || type + " " + info; | |||
badgeData.text[0] = getLabel(type + " " + info, query_data); |
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.
Could you use a template string?
server.js
Outdated
@@ -1784,7 +1784,7 @@ cache(function(queryData, match, sendBadge, request) { | |||
const variants = { | |||
// default use `conda|{channelname}` as label | |||
'': function(queryData, badgeData) { | |||
badgeData.text[0] = (queryData && queryData.label) || 'conda|' + badgeData.text[0]; | |||
badgeData.text[0] = getLabel('conda|' + badgeData.text[0], queryData); |
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.
Could you use a template string? conda|${badgeData.text[0]}
server.js
Outdated
var count = data.items[0].count; | ||
badgeData.text[0] = site + ' ' + item + ' questions'; | ||
var count = parsedData.items[0].count; | ||
badgeData.text[0] = getLabel(site + ' ' + item + ' questions', data); |
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.
Template strings?
Haha, funnily enough I was pair-programming on some Ruby code with a colleague the other day, he also suggested using string templates! My main language is Java, there isn't really anything that straightforward built in natively. 😉 |
All service tests passing locally.
A beautiful thing. 💯 |
Hello,
Quite a few badges were ignoring the override label set by the user (using
?label=healthinesses
in the URL for instance), and were just imposing their own value with calls such asbadgeData.text[0] = 'format';
. Admittedly, some of the badges submitted in my previous pull requests were also misbehaving like this! 😅This piece of work makes sure preference is given to the user defined value if any, by adding missing calls to
getLabel
when the value ofbadgeData.text[0]
is reassigned.Everything seems to still pass locally, nevertheless not sure what to put in the pull request title as the list of service tests to run would probably be a bit too long.
Cheers,
Pyves