def get_jobs()

in src/handlers/resource_report_handler.py [0:0]


    def get_jobs(self, event: ResourceReportJobsGetModel, tenant_name: str):
        tenant_item = self._tenant_service.get(tenant_name)
        tenant_item = modular_helpers.assert_tenant_valid(
            tenant_item, event.customer
        )

        jobs = self.ajs.get_by_tenant_name(
            tenant_name=tenant_name,
            job_type=event.job_type,
            status=JobState.SUCCEEDED,
            start=event.start_iso,
            end=event.end_iso,
        )
        metadata = self._ls.get_customer_metadata(event.customer_id)

        source_response = {}
        for source in self.ajs.to_ambiguous(jobs):
            if source.is_platform_job:
                continue
            if not source.is_ed_job:
                collection = self._report_service.job_collection(
                    tenant_item, source.job
                )
            else:
                collection = self._report_service.ed_job_collection(
                    tenant_item, source.job
                )
            if event.region:
                _LOG.debug(
                    'Region is provided. Fetching only shard with '
                    'this region'
                )
                collection.fetch(region=event.region)
            else:
                _LOG.debug('Region is not provided. Fetching all shards')
                collection.fetch_all()
            collection.meta = self._report_service.fetch_meta(tenant_item)
            matched = MatchedResourcesIterator(
                collection=collection,
                resource_type=event.resource_type,
                region=event.region,
                exact_match=event.exact_match,
                search_by_all=event.search_by_all,
                search_by=event.extras,
            )
            response = ResourceReportBuilder(
                matched_findings_iterator=matched,
                entity=tenant_item,
                full=event.full,
                metadata=metadata,
            ).build()
            if not response:
                _LOG.debug(f'No resources found for job {source}. Skipping')
                continue
            source_response[source] = response
        return build_response(
            content=chain.from_iterable(
                self.dto(s, r) for s, r in source_response.items()
            )
        )