degrade Whoosh egg to 2.4.1, adjust util fnc for pretty intervals

remove debugs
This commit is contained in:
Martin Cech
2015-01-30 13:21:35 -05:00
parent decb4a1ec0
commit c34eddacef
3 changed files with 14 additions and 16 deletions
+1 -1
View File
@@ -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
+7 -7
View File
@@ -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):
@@ -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 = {}