def get_queryset(self, request, is_list=False, *args, **kwargs):
        """Returns a queryset for ToolExecution models.

        By default, this returns all tool executions.

        If the queryset is being used for a list of tool execution resources,
        this is filtered for tool executions matching the given review request
        ID and diff revision arguments. This can be further filtered by the
        optional arguments.
        """
        if is_list:
            review_request_id = request.GET.get('review-request-id')
            diff_revision = request.GET.get('diff-revision')

            q = Q()

            if 'status' in request.GET:
                statuses = request.GET.get('status').split(',')

                for status in statuses:
                    if status in (u'Q', u'R', u'S', u'F', u'T'):
                        q = q | Q(status=status)

            queryset = self.model.objects.filter(
                q,
                review_request_id=review_request_id,
                diff_revision=diff_revision)

            if 'get-latest' in request.GET:
                get_latest = request.GET.get('get-latest')

                if get_latest in ('1', 'true', 'True'):
                    # Get the last-updated tool executions for unique profiles.
                    # This will be used to display the status of each executed
                    # tool profile in the manual execution UI.
                    # Note: We cannot use distinct(profile__id) since it is
                    # only supported on PostgreSQL. Instead, we make use of the
                    # fact that ToolExecution objects are ordered by
                    # last_updated descending.
                    profiles = set()
                    tool_executions = []

                    for tool_execution in queryset:
                        profile = tool_execution.profile.id

                        if profile not in profiles:
                            profiles.add(profile)
                            tool_executions.append(tool_execution)

                    queryset = LocalDataQuerySet(tool_executions)

            return queryset
        else:
            return self.model.objects.all()
dataset/ETHPy150Open reviewboard/ReviewBot/extension/reviewbotext/resources.py/ToolExecutionResource.get_queryset/original