def facets(cls, start_collection, start_entity_id=None, end_collection_id=[], labels=[], types=[], collection_id=[]): facets = {} facets['label'] = cls.facet_array(cls.labels, start_collection, start_entity_id=start_entity_id, end_collection_id=end_collection_id, types=types) facets['type'] = cls.facet_array(cls.types, start_collection, start_entity_id=start_entity_id, end_collection_id=end_collection_id, labels=labels) collection_id = cls.facet_array(cls.end_collection_id, start_collection, start_entity_id=start_entity_id, end_collection_id=collection_id, labels=labels, types=types) objs = Collection.all_by_ids([f['value'] for f in collection_id]) for facet in collection_id: for obj in objs: if facet['value'] == obj.id: facet['label'] = obj.label facets['collection_id'] = collection_id return facets