Esempio n. 1
0
class Query(graphene.ObjectType):
    all_jobs = helpers.OptimizedFilterConnectionField(JobGraph)
    all_job_details = DjangoFilterConnectionField(JobDetailGraph)
    all_build_platforms = graphene.List(BuildPlatformGraph)
    all_machine_platforms = graphene.List(MachinePlatformGraph)
    all_machines = graphene.List(MachineGraph)
    all_option_collections = graphene.List(OptionCollectionGraph)
    all_job_types = graphene.List(JobTypeGraph)
    all_products = graphene.List(ProductGraph)
    all_failure_classifications = graphene.List(FailureClassificationGraph)
    all_pushes = DjangoFilterConnectionField(PushGraph)
    all_text_log_steps = graphene.List(TextLogStepGraph)

    def resolve_all_jobs(self, info, **kwargs):
        return Job.objects.filter(**kwargs)

    def resolve_all_job_details(self, info, **kwargs):
        return JobDetail.objects.filter(**kwargs)

    def resolve_all_build_platforms(self, info, **kwargs):
        return BuildPlatform.objects.all()

    def resolve_all_machine_platforms(self, info, **kwargs):
        return MachinePlatform.objects.all()

    def resolve_all_machines(self, info, **kwargs):
        return Machine.objects.all()

    def resolve_all_option_collections(self, info, **kwargs):
        field_map = {
            "option": ("option", "select"),
        }
        return helpers.optimize(OptionCollection.objects.all(),
                                ast_to_dict(info.field_asts),
                                field_map)

    def resolve_all_job_types(self, info, **kwargs):
        return JobType.objects.all()

    def resolve_all_products(self, info, **kwargs):
        return Product.objects.all()

    def resolve_all_failure_classifications(self, info, **kwargs):
        return FailureClassification.objects.all()

    def resolve_all_pushes(self, info, **kwargs):
        return Push.objects.filter(**kwargs)

    def resolve_all_text_log_steps(self, info, **kwargs):
        return TextLogStep.objects.filter(**kwargs)
Esempio n. 2
0
class PushGraph(DjangoObjectType):
    class Meta:
        model = Push
        filter_fields = ('revision', )
        interfaces = (graphene.relay.Node, )

    jobs = helpers.OptimizedFilterConnectionField(JobGraph)

    def resolve_jobs(self, args, context, info):
        field_map = {
            "buildPlatform": ("build_platform", "select"),
            "jobLog": ("job_log", "prefetch"),
            "jobType": ("job_type", "select"),
            "jobGroup": ("job_group", "select"),
            "failureClassification": ("failure_classification", "prefetch"),
            "failureLine": ("job_log__failure_line", "prefetch"),
            "group": ("job_log__failure_line__group", "prefetch"),
            "textLogStep": ("text_log_step", "prefetch"),
            "errors": ("text_log_step__errors", "prefetch"),
        }
        return helpers.optimize(Job.objects.filter(push=self, **args),
                                ast_to_dict(info.field_asts), field_map)