aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2021-07-08 21:36:51 +0000
committerzsloan2021-07-08 21:36:51 +0000
commitde79d0d5087bf97f59a16327132fd287d57e1c3f (patch)
tree755944c0ee85016a5a21a322a8a35f2c47ecaaa2
parent39f8e4198b2ce6e5859d46c2ba6c055636fafa5f (diff)
downloadgenenetwork2-de79d0d5087bf97f59a16327132fd287d57e1c3f.tar.gz
Don't do calculates for max column widths if there are no new results; previously threw an error
-rw-r--r--wqflask/wqflask/search_results.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index 031a87b3..78d30ba1 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -168,22 +168,23 @@ class SearchResultPage:
trait_dict[key] = trait_dict[key].decode('utf-8')
trait_list.append(trait_dict)
- self.max_widths = {}
- for i, trait in enumerate(trait_list):
- for key in trait.keys():
- if key == "authors":
- authors_string = ",".join(str(trait[key]).split(",")[:6]) + ", et al."
- self.max_widths[key] = max(len(authors_string), self.max_widths[key]) if key in self.max_widths else len(str(trait[key]))
- else:
- self.max_widths[key] = max(len(str(trait[key])), self.max_widths[key]) if key in self.max_widths else len(str(trait[key]))
-
- self.wide_columns_exist = False
- if this_trait.dataset.type == "Publish":
- if (self.max_widths['display_name'] > 25 or self.max_widths['description'] > 100 or self.max_widths['authors']> 80):
- self.wide_columns_exist = True
- if this_trait.dataset.type == "ProbeSet":
- if (self.max_widths['display_name'] > 25 or self.max_widths['symbol'] > 25 or self.max_widths['description'] > 100):
- self.wide_columns_exist = True
+ if self.results:
+ self.max_widths = {}
+ for i, trait in enumerate(trait_list):
+ for key in trait.keys():
+ if key == "authors":
+ authors_string = ",".join(str(trait[key]).split(",")[:6]) + ", et al."
+ self.max_widths[key] = max(len(authors_string), self.max_widths[key]) if key in self.max_widths else len(str(trait[key]))
+ else:
+ self.max_widths[key] = max(len(str(trait[key])), self.max_widths[key]) if key in self.max_widths else len(str(trait[key]))
+
+ self.wide_columns_exist = False
+ if this_trait.dataset.type == "Publish":
+ if (self.max_widths['display_name'] > 25 or self.max_widths['description'] > 100 or self.max_widths['authors']> 80):
+ self.wide_columns_exist = True
+ if this_trait.dataset.type == "ProbeSet":
+ if (self.max_widths['display_name'] > 25 or self.max_widths['symbol'] > 25 or self.max_widths['description'] > 100):
+ self.wide_columns_exist = True
self.trait_list = trait_list