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

Consistent overriding of labels set by the user #1218

Merged
merged 3 commits into from
Nov 1, 2017

Conversation

PyvesB
Copy link
Member

@PyvesB PyvesB commented Oct 29, 2017

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 as badgeData.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 of badgeData.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

@paulmelnikow paulmelnikow added the service-badge New or updated service badge label Oct 30, 2017
Copy link
Member

@paulmelnikow paulmelnikow left a 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);
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

Template strings?

@PyvesB
Copy link
Member Author

PyvesB commented Oct 31, 2017

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. 😉

@paulmelnikow
Copy link
Member

All service tests passing locally.

  288 passing (1m)

A beautiful thing. 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants