コード例 #1
0
ファイル: jobs.py プロジェクト: thelazyoxymoron/treeherder
class JobFilter(django_filters.FilterSet):
    """
    We use this gigantic class to provide the same filtering interface
    as the previous jobs API
    """
    id = django_filters.NumberFilter(name='id')
    project_specific_id = django_filters.NumberFilter(
        name='project_specific_id')
    id__in = NumberInFilter(name='id', lookup_expr='in')
    tier__in = NumberInFilter(name='tier', lookup_expr='in')
    push_id__in = NumberInFilter(name='push_id', lookup_expr='in')
    job_guid = django_filters.CharFilter(name='guid')
    job_guid__in = CharInFilter(name='guid', lookup_expr='in')
    job_coalesced_to_guid = django_filters.CharFilter(name='coalesced_to_guid')
    build_architecture = django_filters.CharFilter(
        name='build_platform__architecture')
    build_os = django_filters.CharFilter(name='build_platform__os_name')
    build_platform = django_filters.CharFilter(name='build_platform__platform')
    build_system_type = django_filters.CharFilter(
        name='signature__build_system_type')
    job_group_id = django_filters.NumberFilter(name='job_group_id')
    job_group_name = django_filters.CharFilter(name='job_group__name')
    job_group_symbol = django_filters.CharFilter(name='job_group__symbol')
    job_type_name = django_filters.CharFilter(name='job_type__name')
    job_type_symbol = django_filters.CharFilter(name='job_type__symbol')
    machine_name = django_filters.CharFilter(name='machine__name')
    machine_platform_architecture = django_filters.CharFilter(
        name='machine_platform__architecture')
    machine_platform_os = django_filters.CharFilter(
        name='machine_platform__os_name')
    platform = django_filters.CharFilter(name='machine_platform__platform')
    ref_data_name = django_filters.CharFilter(name='signature__name')
    signature = django_filters.CharFilter(name='signature__signature')

    class Meta:
        model = Job
        fields = {
            'option_collection_hash': ['exact'],
            'build_platform_id': ['exact'],
            'failure_classification_id': ['exact'],
            'job_type_id': ['exact'],
            'job_group_id': ['exact'],
            'project_specific_id': ['exact'],
            'reason': ['exact'],
            'state': ['exact'],
            'result': ['exact'],
            'who': ['exact'],
            'tier': ['lt', 'lte', 'exact', 'gt', 'gte'],
            'id': ['lt', 'lte', 'exact', 'gt', 'gte'],
            'push_id': ['lt', 'lte', 'exact', 'gt', 'gte'],
            'last_modified': ['lt', 'lte', 'exact', 'gt', 'gte'],
            'submit_time': ['lt', 'lte', 'exact', 'gt', 'gte'],
            'start_time': ['lt', 'lte', 'exact', 'gt', 'gte'],
            'end_time': ['lt', 'lte', 'exact', 'gt', 'gte']
        }
        filter_overrides = {
            django_models.DateTimeField: {
                'filter_class': django_filters.IsoDateTimeFilter
            }
        }
コード例 #2
0
    class JobDetailFilter(django_filters.rest_framework.FilterSet):

        class NumberInFilter(django_filters.filters.BaseInFilter,
                             django_filters.NumberFilter):

            # prevent a non-filter if ``value`` is empty
            # See https://github.com/carltongibson/django-filter/issues/755
            def filter(self, qs, value):
                if value in django_filters.constants.EMPTY_VALUES:
                    raise ParseError("Invalid filter on empty value: {}".format(value))

                return django_filters.Filter.filter(self, qs, value)

        job_id = django_filters.NumberFilter(field_name='job')
        job_id__in = NumberInFilter(field_name='job', lookup_expr='in')
        job_guid = django_filters.CharFilter(field_name='job__guid')
        job__guid = django_filters.CharFilter(field_name='job__guid')  # for backwards compat
        title = django_filters.CharFilter(field_name='title')
        value = django_filters.CharFilter(field_name='value')
        push_id = django_filters.NumberFilter(field_name='job__push')
        repository = django_filters.CharFilter(field_name='job__repository__name')

        class Meta:
            model = JobDetail
            fields = ['job_id', 'job_guid', 'job__guid', 'job_id__in', 'title',
                      'value', 'push_id', 'repository']
    class JobDetailFilter(django_filters.rest_framework.FilterSet):

        job_id = django_filters.NumberFilter(field_name='job')
        job_id__in = NumberInFilter(field_name='job', lookup_expr='in')
        job_guid = django_filters.CharFilter(field_name='job__guid')
        job__guid = django_filters.CharFilter(field_name='job__guid')  # for backwards compat
        title = django_filters.CharFilter(field_name='title')
        value = django_filters.CharFilter(field_name='value')
        push_id = django_filters.NumberFilter(field_name='job__push')
        repository = django_filters.CharFilter(field_name='job__repository__name')

        class Meta:
            model = JobDetail
            fields = ['job_id', 'job_guid', 'job__guid', 'job_id__in', 'title',
                      'value', 'push_id', 'repository']
コード例 #4
0
    class JobDetailFilter(filters.FilterSet):
        class NumberInFilter(django_filters.filters.BaseInFilter,
                             django_filters.NumberFilter):
            pass

        job_id = django_filters.NumberFilter(name='job')
        job_id__in = NumberInFilter(name='job', lookup_expr='in')
        job_guid = django_filters.CharFilter(name='job__guid')
        job__guid = django_filters.CharFilter(
            name='job__guid')  # for backwards compat
        title = django_filters.CharFilter(name='title')
        repository = django_filters.CharFilter(name='job__repository__name')

        class Meta:
            model = JobDetail
            fields = [
                'job_id', 'job_guid', 'job__guid', 'job_id__in', 'title',
                'repository'
            ]