Exemple #1
0
    def save(self, *args, **kwargs):
        """Save instance and start data ingest task for active Provider."""

        should_ingest = False
        # These values determine if a Provider is new
        if self.created_timestamp and not self.setup_complete:
            should_ingest = True

        try:
            provider = Provider.objects.get(uuid=self.uuid)
        except Provider.DoesNotExist:
            pass
        else:
            # These values determine if Provider credentials have been updated:
            if provider.authentication != self.authentication or provider.billing_source != self.billing_source:
                should_ingest = True
            else:
                should_ingest = False

        # Commit the new/updated Provider to the DB
        super().save(*args, **kwargs)

        if settings.AUTO_DATA_INGEST and should_ingest and self.active:
            # Local import of task function to avoid potential import cycle.
            from masu.celery.tasks import check_report_updates

            LOG.info(f"Starting data ingest task for Provider {self.uuid}")
            # Start check_report_updates task after Provider has been committed.
            transaction.on_commit(
                lambda: check_report_updates.delay(provider_uuid=self.uuid))
Exemple #2
0
def download_report(request):
    """Return download file async task ID."""
    params = request.query_params
    provider_uuid = params.get("provider_uuid")
    bill_date = params.get("bill_date")
    async_download_result = check_report_updates.delay(
        provider_uuid=provider_uuid, bill_date=bill_date)
    return Response({"Download Request Task ID": str(async_download_result)})
Exemple #3
0
def download_report():
    """Return download file async task ID."""
    async_download_result = check_report_updates.delay()
    return jsonify({'Download Request Task ID': str(async_download_result)})
Exemple #4
0
def download_report(request):
    """Return download file async task ID."""
    async_download_result = check_report_updates.delay()
    return Response({"Download Request Task ID": str(async_download_result)})