src/pyams_content_es/component/view.py
changeset 71 a991347f4317
parent 49 78867d93d490
equal deleted inserted replaced
70:228b4b58536f 71:a991347f4317
    59             new_params = adapter.get_es_params(context)
    59             new_params = adapter.get_es_params(context)
    60             if new_params:
    60             if new_params:
    61                 params &= new_params
    61                 params &= new_params
    62         return params
    62         return params
    63 
    63 
    64     def get_results(self, context, limit=None):
    64     def get_results(self, context, sort_index, reverse, limit):
    65         view = self.context
       
    66         request = check_request()
    65         request = check_request()
    67         registry = request.registry
    66         registry = request.registry
    68         client = get_client(request)
    67         client = get_client(request)
    69         params = self.get_es_params(context)
    68         params = self.get_es_params(context)
    70         search = Search(using=client.es, index=client.index) \
    69         search = Search(using=client.es, index=client.index) \
    71             .query(params) \
    70             .query(params) \
    72             .sort('{0}workflow.{1}'.format('-' if view.reversed_order else '',
    71             .sort('{0}workflow.{1}'.format('-' if reverse else '',
    73                                            view.order_by)) \
    72                                            sort_index)) \
    74             .source(['internal_id'])
    73             .source(['internal_id'])
    75         if limit:
    74         if limit:
    76             search = search[:limit]
    75             search = search[:limit]
    77         items = CatalogResultSet([result.internal_id for result in search])
    76         items = CatalogResultSet([result.internal_id for result in search])
    78         for name, adapter in sorted(registry.getAdapters((self.context,), IViewQueryFilterExtension),
    77         for name, adapter in sorted(registry.getAdapters((self.context,), IViewQueryFilterExtension),