mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Build and upload the sheet-per-scenario export workbook 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ace3150363
commit
f774ca4424
1 changed files with 24 additions and 1 deletions
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue