mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-08-03 05:18:22 +00:00
Record a rename run's result summary on its sub_task 🟩
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e7785f6b76
commit
694881c110
1 changed files with 25 additions and 4 deletions
|
|
@ -34,17 +34,38 @@ CSV_PATH = os.path.join(
|
|||
|
||||
|
||||
def _summary_json(summary: RenameSummary) -> dict[str, Any]:
|
||||
raise NotImplementedError
|
||||
"""The portal's view of a run, mapped field by field rather than derived
|
||||
from ``RenameSummary``. The explicit mapping is the point: it keeps the
|
||||
portal's contract stable when the internal type is renamed or reshaped, and
|
||||
``outputs`` is serialised to text so it must be plain JSON either way.
|
||||
|
||||
Counts are per-**file**; ``missing_folders`` is per-**property**."""
|
||||
return {
|
||||
"renamed": summary.renamed,
|
||||
"would_rename": summary.would_rename,
|
||||
"skipped_already_canonical": summary.skipped_already_canonical,
|
||||
"skipped_images": summary.skipped_images,
|
||||
"missing_folders": summary.missing_folders,
|
||||
"failed": [
|
||||
{
|
||||
"uprn": failure.uprn,
|
||||
"original_name": failure.original_name,
|
||||
"new_name": failure.new_name,
|
||||
"error": failure.error,
|
||||
}
|
||||
for failure in summary.failed
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@task_handler(task_source="sharepoint_renamer", source=Source.SHAREPOINT_SITE)
|
||||
def handler(body: dict[str, Any], context: Any) -> Any:
|
||||
def handler(body: dict[str, Any], context: Any) -> dict[str, Any]:
|
||||
request = SharepointRenamerRequest.model_validate(body)
|
||||
sp_client = DomnaSharepointClient(resolve_site(request.sharepoint_site))
|
||||
SharepointRenamerOrchestrator(
|
||||
summary = SharepointRenamerOrchestrator(
|
||||
sp_client, CSV_PATH, dry_run=request.dry_run
|
||||
).run()
|
||||
return None
|
||||
return _summary_json(summary)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue