From f8312bff70357847225000100fb1319c63430784 Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Fri, 12 Apr 2024 23:29:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(judge):=20JudgingResult=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=B1=9E=E6=80=A7sum=5Fscore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ccf_parser/results.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ccf_parser/results.py b/ccf_parser/results.py index d6e17d2..caa591b 100644 --- a/ccf_parser/results.py +++ b/ccf_parser/results.py @@ -1,6 +1,6 @@ from typing import Dict, List -from pydantic import BaseModel +from pydantic import BaseModel, computed_field from ccf_parser.status import Status @@ -16,3 +16,14 @@ class CheckPointResult(BaseModel): class JudgingResult(BaseModel): player_order: str problems_result: Dict[str, List[CheckPointResult]] # key: Problem.name + + @computed_field + @property + def sum_score(self) -> int: + score: int = 0 + + for problem_result in self.problems_result.values(): + for ckpt in problem_result: + score += ckpt.score + + return score