feat(admin): show inspection score breakdown

This commit is contained in:
nyan404 committed 2026-09-21 22:31:28 +03:00
1 parent 8241e84757
commit 0b1f2c1063
5 files changed
+25 -5

No files matched your search

+9 -3
View File
@@ -285,6 +285,8 @@ class InspectionReport:
class InspectionResult:
"""Результат расчёта баллов за осмотр."""
points: int
inspection_points: int = 0
resource_points: tuple[dict[str, int | str], ...] = field(default_factory=tuple)
def _inspection_resource_value(name: str) -> int:
@@ -325,6 +327,10 @@ def calculate_inspection(report: InspectionReport) -> InspectionResult:
Формула: осмотры × 2 + сумма (количество × ценность_ресурса)
"""
points = report.inspections * 2
points += sum(amount * _inspection_resource_value(name) for name, amount in report.resources)
return InspectionResult(points=points)
inspection_points = report.inspections * 2
resource_points = tuple(
{"name": name, "amount": amount, "points": amount * _inspection_resource_value(name)}
for name, amount in report.resources
)
points = inspection_points + sum(item["points"] for item in resource_points)
return InspectionResult(points=points, inspection_points=inspection_points, resource_points=resource_points)