From acf114fb60ce493287dc852265a91ef12c854b0b Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 18 Oct 2019 14:35:17 -0500 Subject: Fixed issue with collections ordering --- wqflask/utility/webqtlUtil.py | 5 +++-- wqflask/wqflask/api/gen_menu.py | 6 ++++++ wqflask/wqflask/collect.py | 2 +- wqflask/wqflask/templates/index_page_orig.html | 1 + wqflask/wqflask/user_manager.py | 5 ++++- 5 files changed, 15 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/utility/webqtlUtil.py b/wqflask/utility/webqtlUtil.py index 67a476e3..53661ae4 100644 --- a/wqflask/utility/webqtlUtil.py +++ b/wqflask/utility/webqtlUtil.py @@ -52,11 +52,12 @@ ParInfo ={ 'AXB':['ABF1', 'BAF1', 'C57BL/6J', 'A/J'], 'BXA':['BAF1', 'ABF1', 'C57BL/6J', 'A/J'], 'LXS':['LSF1', 'SLF1', 'ISS', 'ILS'], -'HXBBXH':['HSRBNF1', 'BNHSRF1', 'BN', 'HSR'], +'HXBBXH':['SHR_BNF1', 'BN_SHRF1', 'BN-Lx/Cub', 'SHR/OlaIpcv'], 'BayXSha':['BayXShaF1', 'ShaXBayF1', 'Bay-0','Shahdara'], 'ColXBur':['ColXBurF1', 'BurXColF1', 'Col-0','Bur-0'], 'ColXCvi':['ColXCviF1', 'CviXColF1', 'Col-0','Cvi'], -'SXM':['SMF1', 'MSF1', 'Steptoe','Morex'] +'SXM':['SMF1', 'MSF1', 'Steptoe','Morex'], +'HRDP':['SHR_BNF1', 'BN_SHRF1', 'BN-Lx/Cub', 'SHR/OlaIpcv'] } ######################################### diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py index d7a59f29..77ca6525 100644 --- a/wqflask/wqflask/api/gen_menu.py +++ b/wqflask/wqflask/api/gen_menu.py @@ -1,6 +1,7 @@ from __future__ import print_function, division import sys +import json from flask import g @@ -35,6 +36,11 @@ def gen_dropdown_json(): types=types, datasets=datasets) + output_file = """./wqflask/static/new/javascript/dataset_menu_structure.json""" + + with open(output_file, 'w') as fh: + json.dump(data, fh, indent=3, sort_keys=True) + return data def get_species(): diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 73269c4d..c273af59 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -100,7 +100,7 @@ class AnonCollection(object): collection_exists = True break if collection_exists: - collections_list[collection_position]['members'].extend(self.traits) + collections_list[collection_position]['members'] += list(set(self.traits) - set(collections_list[collection_position]['members'])) collections_list[collection_position]['num_members'] = len(collections_list[collection_position]['members']) collections_list[collection_position]['changed_timestamp'] = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p') else: diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html index f8ea3c7c..bdee6a12 100755 --- a/wqflask/wqflask/templates/index_page_orig.html +++ b/wqflask/wqflask/templates/index_page_orig.html @@ -193,6 +193,7 @@
  • Bayesian Network Web Server at UTHSC
  • GeneNetwork 1 at UTHSC
  • GeneWeaver
  • +
  • PhenoGen at University of Colorado
  • WebGestalt at Baylor
  • diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index b2c7a914..3298c244 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -99,6 +99,8 @@ class AnonUser(object): for collection in collections: collection['created_timestamp'] = datetime.datetime.strptime(collection['created_timestamp'], '%b %d %Y %I:%M%p') collection['changed_timestamp'] = datetime.datetime.strptime(collection['changed_timestamp'], '%b %d %Y %I:%M%p') + + collections = sorted(collections, key = lambda i: i['changed_timestamp'], reverse = True) return collections def import_traits_to_user(self): @@ -234,7 +236,8 @@ class UserSession(object): user_info = response['hits']['hits'][0]['_source'] if 'collections' in user_info.keys(): if len(user_info['collections']) > 0: - return json.loads(user_info['collections']) + collection_list = json.loads(user_info['collections']) + return sorted(collection_list, key = lambda i: datetime.datetime.strptime(i['changed_timestamp'], '%b %d %Y %I:%M%p'), reverse=True) else: return [] else: -- cgit v1.2.3