diff options
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/helper_functions.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py index ecc075ae..50e00421 100644 --- a/wqflask/utility/helper_functions.py +++ b/wqflask/utility/helper_functions.py @@ -57,14 +57,16 @@ def get_trait_db_obs(self, trait_db_list): def get_species_groups(): """Group each species into a group""" _menu = {} + for species, group_name in g.db.execute( "SELECT s.MenuName, i.InbredSetName FROM InbredSet i " "INNER JOIN Species s ON s.SpeciesId = i.SpeciesId " "ORDER BY i.SpeciesId ASC, i.Name ASC").fetchall(): - if _menu.get(species): - _menu = _menu[species].append(group_name) - else: - _menu[species] = [group_name] + if species in _menu: + if _menu.get(species): + _menu = _menu[species].append(group_name) + else: + _menu[species] = [group_name] return [{"species": key, "groups": value} for key, value in list(_menu.items())] |