예제 #1
0
    def get_all(self):
        """
            List all distinct filters.

            Handles requests:
                GET /executions/views/filters
        """
        filters = {}

        for name, field in six.iteritems(SUPPORTED_FILTERS):
            if name not in IGNORE_FILTERS:
                if isinstance(field, six.string_types):
                    query = '$' + field
                else:
                    dot_notation = list(chain.from_iterable(
                        ('$' + item, '.') for item in field
                    ))
                    dot_notation.pop(-1)
                    query = {'$concat': dot_notation}

                aggregate = ActionExecution.aggregate([
                    {'$match': {'parent': None}},
                    {'$group': {'_id': query}}
                ])

                filters[name] = [res['_id'] for res in aggregate['result'] if res['_id']]

        return filters
예제 #2
0
    def get_all(self):
        """
            List all distinct filters.

            Handles requests:
                GET /executions/views/filters
        """
        filters = {}

        for name, field in six.iteritems(SUPPORTED_FILTERS):
            if name not in IGNORE_FILTERS:
                if isinstance(field, six.string_types):
                    query = '$' + field
                else:
                    dot_notation = list(
                        chain.from_iterable(
                            ('$' + item, '.') for item in field))
                    dot_notation.pop(-1)
                    query = {'$concat': dot_notation}

                aggregate = ActionExecution.aggregate([{
                    '$match': {
                        'parent': None
                    }
                }, {
                    '$group': {
                        '_id': query
                    }
                }])

                filters[name] = [
                    res['_id'] for res in aggregate['result'] if res['_id']
                ]

        return filters
예제 #3
0
    def get_all(self):
        """
            List all distinct filters.

            Handles requests:
                GET /executions/views/filters
        """
        filters = {}

        for name, field in six.iteritems(SUPPORTED_FILTERS):
            if name not in IGNORE_FILTERS:
                if isinstance(field, six.string_types):
                    query = "$" + field
                else:
                    dot_notation = list(chain.from_iterable(("$" + item, ".") for item in field))
                    dot_notation.pop(-1)
                    query = {"$concat": dot_notation}

                aggregate = ActionExecution.aggregate([{"$match": {"parent": None}}, {"$group": {"_id": query}}])

                filters[name] = [res["_id"] for res in aggregate["result"] if res["_id"]]

        return filters