#NEWLINE# def convert_collections( facet ) : #NEWLINE# #INDENT# output = { #NEWLINE# #INDENT# 'values' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# ids = [ b . get ( 'key' ) for b in facet . get ( 'buckets' , [ ] ) ] #NEWLINE# collections = Collection . all_by_ids ( ids ) . all ( ) #NEWLINE# for bucket in facet . get ( 'buckets' , [ ] ) : #NEWLINE# #INDENT# key = bucket . get ( 'key' ) #NEWLINE# for collection in collections : #NEWLINE# #INDENT# if ( collection . id != key ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# output [ 'values' ] . append ( { #NEWLINE# #INDENT# 'id' : key , #NEWLINE# 'label' : collection . label , #NEWLINE# 'count' : bucket . get ( 'doc_count' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# return output