def _get_creator_counts(query, count, page):
 creator_counts = query.facet_counts()['creator_id']['terms']
 total = len(creator_counts)
 creator_counts = creator_counts[((page - 1) * count):(page * count)]
 user_ids = [x['term'] for x in creator_counts]
 results = UserMappingType.search().filter(id__in=user_ids).values_dict('id', 'username', 'display_name', 'avatar', 'twitter_usernames', 'last_contribution_date')[:count]
 results = UserMappingType.reshape(results)
 user_lookup = {}
 for r in results:
  lcd = r.get('last_contribution_date', None)
  if lcd:
   delta = (datetime.now() - lcd)
   r['days_since_last_activity'] = delta.days
  else:
   r['days_since_last_activity'] = None
  user_lookup[r['id']] = r
 for item in creator_counts:
  item['user'] = user_lookup.get(item['term'], None)
 return ([item for item in creator_counts if (item['user'] is not None)], total)

def _get_creator_counts ( query , count , page ) : creator_counts = query . facet_counts ( ) [ 'creator_id' ] [ 'terms' ] total = len ( creator_counts ) creator_counts = creator_counts [ ( ( page - 1 ) * count ) : ( page * count ) ] user_ids = [ x [ 'term' ] for x in creator_counts ] results = UserMappingType . search ( ) . filter ( id__in = user_ids ) . values_dict ( 'id' , 'username' , 'display_name' , 'avatar' , 'twitter_usernames' , 'last_contribution_date' ) [ : count ] results = UserMappingType . reshape ( results ) user_lookup = { } for r in results : lcd = r . get ( 'last_contribution_date' , None ) if lcd : delta = ( datetime . now ( ) - lcd ) r [ 'days_since_last_activity' ] = delta . days else : r [ 'days_since_last_activity' ] = None user_lookup [ r [ 'id' ] ] = r for item in creator_counts : item [ 'user' ] = user_lookup . get ( item [ 'term' ] , None ) return ( [ item for item in creator_counts if ( item [ 'user' ] is not None ) ] , total )
get the list of top contributors with the contribution count .