Auto-fixed categories: - F401: unused imports removed - I001: import blocks sorted - W293: trailing whitespace stripped - UP035: deprecated typing imports replaced - SIM: simplify suggestions applied - ARG: unused args prefixed with underscore - T201: print statements removed - F841: unused variables removed - RUF059: unpacked variables prefixed Remaining ~1500 unfixable errors (C901, B904, N806, E402) require manual work. Backend smoke tests: 13/13 passed.
57 lines
2.3 KiB
Python
57 lines
2.3 KiB
Python
# #region clean_release_mappers [C:3] [TYPE Module] [SEMANTICS clean-release, mapper, dto, entity, transform]
|
|
# @BRIEF Map between domain entities (SQLAlchemy models) and DTOs.
|
|
# @LAYER: Application
|
|
# @RELATION DEPENDS_ON -> clean_release_dto
|
|
|
|
from src.models.clean_release import ComplianceReport, ComplianceRun, DistributionManifest, ReleaseCandidate
|
|
from src.services.clean_release.dto import CandidateDTO, ComplianceRunDTO, ManifestDTO, ReportDTO
|
|
from src.services.clean_release.enums import CandidateStatus, ComplianceDecision, RunStatus
|
|
|
|
|
|
def map_candidate_to_dto(candidate: ReleaseCandidate) -> CandidateDTO:
|
|
return CandidateDTO(
|
|
id=candidate.id,
|
|
version=candidate.version,
|
|
source_snapshot_ref=candidate.source_snapshot_ref,
|
|
build_id=candidate.build_id,
|
|
created_at=candidate.created_at,
|
|
created_by=candidate.created_by,
|
|
status=CandidateStatus(candidate.status)
|
|
)
|
|
|
|
def map_manifest_to_dto(manifest: DistributionManifest) -> ManifestDTO:
|
|
return ManifestDTO(
|
|
id=manifest.id,
|
|
candidate_id=manifest.candidate_id,
|
|
manifest_version=manifest.manifest_version,
|
|
manifest_digest=manifest.manifest_digest,
|
|
artifacts_digest=manifest.artifacts_digest,
|
|
created_at=manifest.created_at,
|
|
created_by=manifest.created_by,
|
|
source_snapshot_ref=manifest.source_snapshot_ref,
|
|
content_json=manifest.content_json or {}
|
|
)
|
|
|
|
def map_run_to_dto(run: ComplianceRun) -> ComplianceRunDTO:
|
|
return ComplianceRunDTO(
|
|
run_id=run.id,
|
|
candidate_id=run.candidate_id,
|
|
status=RunStatus(run.status),
|
|
final_status=ComplianceDecision(run.final_status) if run.final_status else None,
|
|
task_id=run.task_id
|
|
)
|
|
|
|
def map_report_to_dto(report: ComplianceReport) -> ReportDTO:
|
|
# Note: ReportDTO in dto.py is a compact view
|
|
return ReportDTO(
|
|
report_id=report.id,
|
|
candidate_id=report.candidate_id,
|
|
final_status=ComplianceDecision(report.final_status),
|
|
policy_version="unknown", # Would need to resolve from run/snapshot
|
|
manifest_digest="unknown", # Would need to resolve from run/manifest
|
|
violation_count=0, # Would need to resolve from violations
|
|
generated_at=report.generated_at
|
|
)
|
|
|
|
# #endregion clean_release_mappers
|