Пример #1
0
    def listing(self,
                system=None,
                file_path=None,
                offset=0,
                limit=100,
                **kwargs):
        """Perform the search and output in a serializable format."""

        query = self.construct_query(system, file_path, **kwargs)
        listing_search = Search()
        listing_search = listing_search.filter(query).sort(
            '_index', {'created': {
                'order': 'desc',
                'unmapped_type': 'long'
            }})
        listing_search = listing_search.extra(
            from_=offset, size=limit).source(includes=[
                'project.value', 'created', 'projectId', 'users', 'system'
            ])
        res = listing_search.execute()
        children = []
        for hit in res:
            hit_to_file = BaseESPublication.hit_to_file(hit)
            children.append(hit_to_file)
        result = {
            'trail': [{
                'name': '$SEARCH',
                'path': '/$SEARCH'
            }],
            'name': '$SEARCH',
            'path': '/',
            'system': system,
            'type': 'dir',
            'children': children,
            'permissions': 'READ'
        }
        return result
Пример #2
0
    def listing(self,
                system=None,
                file_path=None,
                offset=0,
                limit=100,
                **kwargs):
        """Perform the search and output in a serializable format."""

        query = self.construct_query(system, file_path, **kwargs)
        listing_search = Search()
        listing_search = listing_search.filter(query).sort('_index')
        listing_search = listing_search.extra(from_=offset, size=limit)
        res = listing_search.execute()
        children = []
        for hit in res:
            try:
                getattr(hit, 'projectId')
                hit_to_file = BaseESPublication.hit_to_file(hit)
                children.append(hit_to_file)
            except AttributeError:
                children.append(
                    BaseESPublicationLegacy(**hit.to_dict()).to_file())

        result = {
            'trail': [{
                'name': '$SEARCH',
                'path': '/$SEARCH'
            }],
            'name': '$SEARCH',
            'path': '/',
            'system': system,
            'type': 'dir',
            'children': children,
            'permissions': 'READ'
        }
        return result