Skip to content
Permalink
Browse files
Pass the along the error for too many matches
This avoid having the situation where by having exactly 40 relays we
mistakenly state that there are too many.
  • Loading branch information
hellais committed Jun 10, 2016
1 parent df04397 commit e2b19792c8d67077af0db1613fee0cdd5067e042
Showing with 14 additions and 10 deletions.
  1. +4 −1 js/collections/results.js
  2. +5 −3 js/router.js
  3. +3 −3 js/views/search/do.js
  4. +2 −3 templates/search/do.html
@@ -12,6 +12,7 @@ define([
lookup: function(options) {
var success = options.success;
var error = options.error;
var err = 0;
var collection = this;
options.success = $.getJSON(this.url, function(response) {
this.fresh_until = response.fresh_until;
@@ -38,12 +39,14 @@ define([
} else if (relays.length > 40) {
/* Truncate result set beyond 40 hits. */
relays = relays.slice(0, 40);
err = 4;
console.log(options);
}
_.each(relays, function(relay) {
relay.lookup({
success: function(){
collection[options.add ? 'add' : 'reset'](relays, options);
success(collection, relays);
success(err);
return relays;
},
error: function() {
@@ -66,16 +66,18 @@ define([
doSearchView.collection.url =
doSearchView.collection.baseurl + this.hashFingerprints(query);
doSearchView.collection.lookup({
success: function(relays){
success: function(err){
$("#content").show();
doSearchView.relays = doSearchView.collection.models;
doSearchView.error = err;
doSearchView.render(query);
$("#loading").hide();
},

error: function(erno){
error: function(err){
$("#content").show();
doSearchView.error(erno);
doSearchView.error = err;
doSearchView.renderError();
$("#loading").hide();
}
});
@@ -148,7 +148,7 @@ define([
document.title = "Atlas";
this.filtering();
var asInitVals = new Array();
var compiledTemplate = _.template(doSearchTemplate, {relays: this.relays, countries: CountryCodes});
var compiledTemplate = _.template(doSearchTemplate, {relays: this.relays, countries: CountryCodes, error: this.error});
this.el.html(compiledTemplate);
$("#loading").hide();
var fp = this;
@@ -227,8 +227,8 @@ define([

},

error: function(err){
var compiledTemplate = _.template(doSearchTemplate, {relays: null, error: err});
renderError: function(){
var compiledTemplate = _.template(doSearchTemplate, {relays: null, error: this.error, countries: null});
$("#loading").hide();
this.el.html(compiledTemplate);
}
@@ -21,9 +21,9 @@
</div>
<% } %>
<% } else { %>
<% if (relays.length >= 40) {%>
<% if (error == 4) {%>
<div class="alert alert-warning">
<strong>Possibly too many matches!</strong><p>The current version of
<strong>Too many matches!</strong><p>The current version of
Atlas does not support a result set greater than 40 and only displays
the first 40 hits. This is due to some performance issues in doing
multiple parallel connections in javascript. Future versions will
@@ -48,7 +48,6 @@
<% var i = 0; %>

<% _.each(relays, function(relay) { %>
<% if (i > 40) return true; %>
<% if (i % 2 == 0 ) { %>
<tr class="even">
<% } else { %>

0 comments on commit e2b1979

Please sign in to comment.