Skip to content

Commit

Permalink
fix: fix not working online results
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-karpov committed Jan 13, 2025
1 parent d69a0e8 commit 3ac1629
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## next

* Fix not working online results when the settings responsible for timing are missing

## 2024-10-07 v1.7.1

- Rebuild indexes after major changing/deleting bibs and cards operations
Expand Down
1 change: 1 addition & 0 deletions changelog_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## next

+ Добавлена возможность выбрать директорию с шаблонами
+ Исправление не отправляющихся результатов онлайн при отсутствии группы настроек, отвечающих за хронометраж ([#472](https://github.com/sportorg/pysport/issues/472))

## 2024-10-07 v1.7.1

Expand Down
23 changes: 13 additions & 10 deletions sportorg/modules/live/orgeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ def _get_person_obj(data, race_data, result=None):
result["result_msec"] / 10
) # 1/100 sec - proprietary format

if race_data["settings"]["result_processing_mode"] == "ardf":
if race_data["settings"].get("result_processing_mode", "time") == "ardf":
obj["score"] = result["scores_ardf"]
elif race_data["settings"]["result_processing_mode"] == "scores":
elif race_data["settings"].get("result_processing_mode", "time") == "scores":
obj["score"] = result["rogaine_score"]
if result["rogaine_penalty"] > 0:
obj["penalty"] = str(result["rogaine_penalty"])
Expand All @@ -139,9 +139,8 @@ def _get_person_obj(data, race_data, result=None):
obj["splits"] = []
splits = []
for split in result["splits"]:
if (
split["is_correct"]
or race_data["settings"]["live_sending_all_controls"]
if split["is_correct"] or race_data["settings"].get(
"live_sending_all_controls", False
):
splits.append(split)
for i in range(len(splits)):
Expand Down Expand Up @@ -258,7 +257,7 @@ async def create_online_cp(url, data, race_data, log, *, session):
race_data is Dict: Race
"""

if not race_data["settings"]["live_cp_enabled"]:
if not race_data["settings"].get("live_cp_enabled", False):
return

o = Orgeo(session, url)
Expand All @@ -276,7 +275,7 @@ async def create_online_cp(url, data, race_data, log, *, session):
try:
res = _get_result_by_id(item, race_data)

if res and race_data["settings"]["live_cp_finish_enabled"]:
if res and race_data["settings"].get("live_cp_finish_enabled", True):
# send finish time as cp with specified code

card_number = res["card_number"]
Expand All @@ -286,7 +285,7 @@ async def create_online_cp(url, data, race_data, log, *, session):
card_number = person["card_number"]

if card_number > 0:
code = race_data["settings"]["live_cp_code"]
code = race_data["settings"].get("live_cp_code", "10")
finish_time = OTime.now()
if res["finish_time"] is not None:
finish_time = int_to_otime(
Expand All @@ -305,7 +304,7 @@ async def create_online_cp(url, data, race_data, log, *, session):
else:
log.info(LOG_MSG, 401, "Ignoring empty card number")

if res and race_data["settings"]["live_cp_splits_enabled"]:
if res and race_data["settings"].get("live_cp_splits_enabled", True):
# send split as cp, codes of cp to send are set by the list

card_number = res["card_number"]
Expand All @@ -315,7 +314,11 @@ async def create_online_cp(url, data, race_data, log, *, session):
card_number = person["card_number"]

if card_number > 0:
codes = race_data["settings"]["live_cp_split_codes"].split(",")
codes = (
race_data["settings"]
.get("live_cp_split_codes", "91,91,92")
.split(",")
)
for split in res["splits"]:
if split["code"] in codes:
split_time = int_to_otime(split["time"] // 10).to_str()
Expand Down
4 changes: 3 additions & 1 deletion sportorg/modules/sportident/result_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ 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 = time_to_otime(datetime.fromtimestamp(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 3ac1629

Please sign in to comment.