def process_report(report): """ Process line item report and kick off summarization celery task. Args: report (Dict) - keys: value file: String, cluster_id: String, payload_date: DateTime, manifest_path: String, uuid: String, manifest_path: String Returns: None """ cluster_id = report.get('cluster_id') provider_uuid = utils.get_provider_uuid_from_cluster_id(cluster_id) if provider_uuid: LOG.info('Found provider_uuid: %s for cluster_id: %s', str(provider_uuid), str(cluster_id)) account = get_account(provider_uuid) LOG.info('Processing report for account %s', account) reports_to_summarize = get_report_files(**account) LOG.info('Processing complete for account %s', account) async_id = summarize_reports.delay(reports_to_summarize) LOG.info('Summarization celery uuid: %s', str(async_id)) else: LOG.error('Could not find provider_uuid for cluster_id: %s', str(cluster_id))
def summarize_manifest(report_meta): """ Kick off manifest summary when all report files have completed line item processing. Args: report (Dict) - keys: value schema_name: String, manifest_id: Integer, provider_uuid: String, provider_type: String, Returns: Celery Async UUID. """ async_id = None schema_name = report_meta.get("schema_name") manifest_id = report_meta.get("manifest_id") provider_uuid = report_meta.get("provider_uuid") schema_name = report_meta.get("schema_name") provider_type = report_meta.get("provider_type") with ReportManifestDBAccessor() as manifest_accesor: manifest = manifest_accesor.get_manifest_by_id(manifest_id) if manifest.num_processed_files == manifest.num_total_files: report_meta = { "schema_name": schema_name, "provider_type": provider_type, "provider_uuid": provider_uuid, "manifest_id": manifest_id, } async_id = summarize_reports.delay([report_meta]) return async_id
def process_report(report): """ Process line item report and kick off summarization celery task. Args: report (Dict) - keys: value file: String, cluster_id: String, date: DateTime, manifest_path: String, uuid: String, manifest_path: String Returns: None """ cluster_id = report.get("cluster_id") provider_uuid = utils.get_provider_uuid_from_cluster_id(cluster_id) if provider_uuid: LOG.info("Found provider_uuid: %s for cluster_id: %s", str(provider_uuid), str(cluster_id)) account = get_account(provider_uuid) if account: payload_date = report.get("date") report_month = payload_date.replace(day=1, second=1, microsecond=1).date() account["report_month"] = str(report_month) LOG.info("Processing %s report for account %s", payload_date.strftime("%B %Y"), account) reports_to_summarize = get_report_files(**account) LOG.info("Processing complete for account %s", account) async_id = summarize_reports.delay(reports_to_summarize) LOG.info("Summarization celery uuid: %s", str(async_id)) else: LOG.error("Could not find provider_uuid for cluster_id: %s", str(cluster_id))
def summarize_manifest(report_meta): """ Kick off manifest summary when all report files have completed line item processing. Args: report (Dict) - keys: value schema_name: String, manifest_id: Integer, provider_uuid: String, provider_type: String, Returns: Celery Async UUID. """ async_id = None schema_name = report_meta.get("schema_name") manifest_id = report_meta.get("manifest_id") provider_uuid = report_meta.get("provider_uuid") schema_name = report_meta.get("schema_name") provider_type = report_meta.get("provider_type") start_date = report_meta.get("start") end_date = report_meta.get("end") with ReportManifestDBAccessor() as manifest_accesor: if manifest_accesor.manifest_ready_for_summary(manifest_id): report_meta = { "schema_name": schema_name, "provider_type": provider_type, "provider_uuid": provider_uuid, "manifest_id": manifest_id, } if start_date and end_date: report_meta["start"] = start_date report_meta["end"] = end_date async_id = summarize_reports.delay([report_meta]) return async_id