From f774ca44241ad5ddb9149afce6cf3c44ce1ddb2e Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 14 Jul 2026 09:27:25 +0000 Subject: [PATCH] =?UTF-8?q?Build=20and=20upload=20the=20sheet-per-scenario?= =?UTF-8?q?=20export=20workbook=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- orchestration/scenario_export_orchestrator.py | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/orchestration/scenario_export_orchestrator.py b/orchestration/scenario_export_orchestrator.py index 5accfc951..a45f912e7 100644 --- a/orchestration/scenario_export_orchestrator.py +++ b/orchestration/scenario_export_orchestrator.py @@ -16,6 +16,7 @@ from dataclasses import dataclass from typing import Protocol, Sequence from domain.scenario_export.scenario_sheet import ( + ExportSheet, PropertyScenarioData, shape_scenario_sheet, ) @@ -78,4 +79,26 @@ class ScenarioExportOrchestrator: recipient_email: str, export_name: str, ) -> ScenarioExportResult: - raise NotImplementedError + named_sheets: list[tuple[str, ExportSheet]] = [] + row_count = 0 + for scenario_id in scenario_ids: + rows = self._rows.rows_for( + portfolio_id=portfolio_id, + scenario_id=scenario_id, + property_ids=property_ids, + ) + sheet = shape_scenario_sheet(rows) + named_sheets.append((self._scenarios.name_for(scenario_id), sheet)) + row_count += len(sheet.rows) + + data = render_workbook(named_sheets) + key = f"{self._key_prefix}/{export_name}.xlsx" + self._exports.put_object(key, data) + url = self._exports.generate_presigned_url(key, self._url_ttl_seconds) + + return ScenarioExportResult( + presigned_url=url, + export_s3_key=key, + sheet_count=len(named_sheets), + row_count=row_count, + )