From f5997f1e14a2acc14a78f690ecd5d90ee501ceff Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 12 Feb 2024 19:10:20 +0100 Subject: If JFR webpage segment is not explicitly running, still count real number of boards "played" (visible in the scoresheet) in it. This is so that when something's wrong (like, a board is erroneously hidden) only that board is not counted, and not the entire segment. --- jfr_playoff/data/match/jfrhtml.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jfr_playoff/data/match/jfrhtml.py b/jfr_playoff/data/match/jfrhtml.py index a869811..5285a8a 100644 --- a/jfr_playoff/data/match/jfrhtml.py +++ b/jfr_playoff/data/match/jfrhtml.py @@ -129,13 +129,13 @@ class JFRHtmlMatchInfo(MatchInfoClient): PlayoffLogger.get('match.jfrhtml').info( 'HTML played boards count for segment: %d/%d', played_boards, board_count) - return board_count, played_boards >= board_count + return board_count, played_boards except IOError as e: PlayoffLogger.get('match.jfrhtml').info( 'cannot fetch played boards count for segment: %s(%s)', type(e).__name__, str(e)) - return 0, False - return 0, False + return 0, 0 + return 0, 0 def board_count(self): row = self._find_table_row(self.settings['link']) @@ -166,9 +166,12 @@ class JFRHtmlMatchInfo(MatchInfoClient): in running_segments]) finished_segments = [] boards_in_segment = None + played_boards = 0 for segment in segments: if segment not in running_segments: - boards, is_finished = self._get_finished_info(segment) + boards, played = self._get_finished_info(segment) + is_finished = played >= boards + played_boards += played if is_finished: finished_segments.append(segment) if boards_in_segment is None and boards > 0: @@ -186,9 +189,7 @@ class JFRHtmlMatchInfo(MatchInfoClient): total_boards = ( len(segments) + len(towels) + len(running_segments)) \ * boards_in_segment - played_boards = (len(towels) + len(finished_segments)) \ - * boards_in_segment \ - + running_boards + played_boards += running_boards PlayoffLogger.get('match.jfrhtml').info( 'board count: %d/%d', played_boards, total_boards) return played_boards, total_boards -- cgit v1.2.3