#NEWLINE# @ jsonify #NEWLINE# @ cherrypy . expose #NEWLINE# @ functools . lru_cache ( 100 ) #NEWLINE# def get_starred( self , room = '' ) : #NEWLINE# #INDENT# if self . get_user ( ) : #NEWLINE# #INDENT# last_atime = ( time . time ( ) - ( ( 60 * 60 ) * 24 ) ) #NEWLINE# data = self . db . request ( 'GET' , ( '/%s_room_%s_messages/_design/messages/_view/by_date/?startkey=%s' % ( self . couchdb_prefix , room , json . dumps ( float ( last_atime ) ) ) ) ) #NEWLINE# if ( 'rows' in data ) : #NEWLINE# #INDENT# data = [ i [ 'value' ] for i in data [ 'rows' ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = [ ] #NEWLINE# #UNINDENT# for i in data : #NEWLINE# #INDENT# i [ 'user' ] = self . find_user ( i [ 'user' ] ) #NEWLINE# del i [ 'user' ] [ 'email' ] #NEWLINE# del i [ 'user' ] [ 'identity' ] #NEWLINE# del i [ 'user' ] [ 'website' ] #NEWLINE# del i [ 'user' ] [ 'creation_date' ] #NEWLINE# del i [ 'user' ] [ 'openid_provider' ] #NEWLINE# del i [ 'user' ] [ 'country' ] #NEWLINE# del i [ 'user' ] [ '_rev' ] #NEWLINE# del i [ 'user' ] [ 'messages' ] #NEWLINE# del i [ 'user' ] [ 'last_login_date' ] #NEWLINE# del i [ 'user' ] [ 'last_login_ip' ] #NEWLINE# del i [ 'user' ] [ 'about_me' ] #NEWLINE# del i [ 'user' ] [ 'owns_rooms' ] #NEWLINE# del i [ 'user' ] [ 'birthday' ] #NEWLINE# del i [ 'user' ] [ 'last_seen_date' ] #NEWLINE# i [ 'user' ] [ 'name' ] = self . safe ( i [ 'user' ] [ 'name' ] ) #NEWLINE# #UNINDENT# data = sorted ( data , key = ( lambda x : len ( x [ 'stars' ] ) ) , reverse = True ) #NEWLINE# data = list ( ( i for i in data if i [ 'stars' ] ) ) [ : 10 ] #NEWLINE# data = sorted ( data , key = ( lambda x : x [ 'date' ] ) , reverse = True ) #NEWLINE# cherrypy . response . headers [ 'Content-Type' ] = 'application/json' #NEWLINE# h = hashlib . md5 ( '' . join ( ( ( i [ '_id' ] + str ( len ( i [ 'stars' ] ) ) ) for i in data ) ) . encode ( ) ) . hexdigest ( ) #NEWLINE# for i in data : #NEWLINE# #INDENT# i [ 'nice_date' ] = time . strftime ( '%Y-%m-%d %H:%MZ' , time . gmtime ( i [ 'date' ] ) ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'last_atime' : last_atime , #NEWLINE# 'data' : data , #NEWLINE# 'hash' : h , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# raise cherrypy . HTTPError ( 404 )