Skip to content

Commit

Permalink
Stop sending extra empty search request
Browse files Browse the repository at this point in the history
Requests for citation_count being sent even if not sorting by citations, this will now stop those requests
  • Loading branch information
thostetler committed Nov 19, 2020
1 parent 06a3d1d commit 0a5c537
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/js/widgets/search_bar/search_bar_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,20 +863,22 @@ define([

dispatchRequest: function(apiQuery) {
var sort = apiQuery.get('sort');
var da = this.defaultQueryArguments;
if (/citation_count_norm/i.test(sort)) {
da = _.extend(da, {
this.defaultQueryArguments = _.extend(this.defaultQueryArguments, {
stats: 'true',
'stats.field': 'citation_count_norm',
});
} else if (/citation_count/i.test(sort)) {
da = _.extend(da, {
this.defaultQueryArguments = _.extend(this.defaultQueryArguments, {
stats: 'true',
'stats.field': 'citation_count',
});
} else {
this.model.unset('citationCount');
this.model.unset('citationLabel');

// don't bother sending request
return;
}
BaseWidget.prototype.dispatchRequest.call(this, apiQuery);
},
Expand Down

0 comments on commit 0a5c537

Please sign in to comment.