From c34eddacefbcefe9f8f316077e3a4adc3bcb36a8 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Fri, 30 Jan 2015 13:21:35 -0500 Subject: [PATCH] degrade Whoosh egg to 2.4.1, adjust util fnc for pretty intervals remove debugs --- eggs.ini | 2 +- lib/galaxy/util/__init__.py | 14 +++++++------- lib/galaxy/webapps/tool_shed/search/repo_search.py | 14 ++++++-------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/eggs.ini b/eggs.ini index 1e80e2eef0a..99f2718a4ff 100644 --- a/eggs.ini +++ b/eggs.ini @@ -73,7 +73,7 @@ WebOb = 0.8.5 wsgiref = 0.1.2 Babel = 1.3 wchartype = 0.1 -Whoosh = 2.5.7 +Whoosh = 2.4.1 ; fluent_logger = 0.3.3 raven = 3.1.8 diff --git a/lib/galaxy/util/__init__.py b/lib/galaxy/util/__init__.py index d83ec60feca..006dbed7f16 100644 --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -371,7 +371,7 @@ def pretty_print_time_interval( time = False, precise = False ): if second_diff < 86400: return str(second_diff / 3600) + " hours ago" if day_diff == 1: - return "Yesterday" + return "yesterday" if day_diff < 7: return str( day_diff ) + " days ago" if day_diff < 31: @@ -381,16 +381,16 @@ def pretty_print_time_interval( time = False, precise = False ): return str( day_diff / 365 ) + " years ago" else: if day_diff == 0: - return "Today" + return "today" if day_diff == 1: - return "Yesterday" + return "yesterday" if day_diff < 7: - return "this week" + return "less than a week" if day_diff < 31: - return "this month" + return "less than a month" if day_diff < 365: - return "this year" - return str( day_diff / 365 ) + " years ago" + return "less than a year" + return "a few years ago" def pretty_print_json(json_data, is_json_string=False): diff --git a/lib/galaxy/webapps/tool_shed/search/repo_search.py b/lib/galaxy/webapps/tool_shed/search/repo_search.py index 5068ab40e8c..32566cffeca 100644 --- a/lib/galaxy/webapps/tool_shed/search/repo_search.py +++ b/lib/galaxy/webapps/tool_shed/search/repo_search.py @@ -45,7 +45,7 @@ class RepoWeighting( scoring.BM25F ): use_final = True def final( self, searcher, docnum, score ): - log.debug('score before: ' + str(score) ) + # log.debug('score before: ' + str(score) ) # Arbitrary for now reasonable_hits = 100.0 @@ -59,15 +59,15 @@ class RepoWeighting( scoring.BM25F ): if times_downloaded == 0: times_downloaded = 1 popularity_modifier = ( times_downloaded / reasonable_hits ) - log.debug('popularity_modifier: ' + str(popularity_modifier) ) + # log.debug('popularity_modifier: ' + str(popularity_modifier) ) cert_modifier = 2 if searcher.stored_fields( docnum )[ "approved" ] == 'yes' else 1 - log.debug('cert_modifier: ' + str(cert_modifier) ) + # log.debug('cert_modifier: ' + str(cert_modifier) ) # Adjust the computed score for this document by the popularity # and by the certification level. final_score = score * popularity_modifier * cert_modifier - log.debug('score after: ' + str( final_score ) ) + # log.debug('score after: ' + str( final_score ) ) return final_score @@ -108,16 +108,14 @@ class RepoSearch( object ): 'remote_repository_url', 'repo_owner_username' ], schema = schema ) - # user_query = parser.parse( search_term ) user_query = parser.parse( '*' + search_term + '*' ) - - # hits = searcher.search( user_query, terms = True ) hits = searcher.search_page( user_query, page, pagelen = 10, terms = True ) + log.debug( 'searching for: #' + str( search_term ) ) log.debug( 'total hits: ' + str( len( hits ) ) ) log.debug( 'scored hits: ' + str( hits.scored_length() ) ) results = {} - results[ 'total_results'] = str( hits.scored_length() ) + results[ 'total_results'] = str( len( hits ) ) results[ 'hits' ] = [] for hit in hits: hit_dict = {}