Skip to content

Commit

Permalink
Use FinishSource enum for missed finish.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeikobelev committed Jan 5, 2025
1 parent 1705d80 commit d69a0e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sportorg/modules/sportident/result_generation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import logging
from copy import deepcopy
from datetime import datetime
from enum import Enum

from sportorg.common.otime import OTime
from sportorg.gui.dialogs.bib_dialog import BibDialog
from sportorg.language import translate
from sportorg.models.memory import Person, ResultSportident, ResultStatus, race
from sportorg.models.result.result_checker import ResultChecker, ResultCheckerException
from sportorg.utils.time import time_to_otime


class FinishSource(Enum):
Expand All @@ -30,7 +32,9 @@ def __init__(self, result: ResultSportident):
"system_duplicate_chip_processing", "several_results"
)
self.card_read_repeated = self.duplicate_chip_processing == "bib_request"
self.missed_finish = race().get_setting("system_missed_finish", "zero")
self.missed_finish = FinishSource[
race().get_setting("system_missed_finish", "zero")
]
self.finish_source = FinishSource[
race().get_setting("system_finish_source", "station")
]
Expand All @@ -40,7 +44,7 @@ def _process_missed_finish(self):
if self._result and self._result.finish_time is None:
if self.finish_source == FinishSource.station:
if self.missed_finish == FinishSource.readout:
self._result.finish_time = self._result.created_at
self._result.finish_time = time_to_otime(datetime.fromtimestamp(self._result.created_at))
elif self.missed_finish == FinishSource.zero:
self._result.finish_time = OTime(msec=0)
elif self.missed_finish == FinishSource.dsq:
Expand Down

0 comments on commit d69a0e8

Please sign in to comment.