Skip to content

Commit 0879c71

Browse files
committed
Fix(viewer): Harden against zerodivision error
1 parent 0b34cf5 commit 0879c71

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

codeclash/viewer/templates/includes/rounds.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h2>🎯 Detailed Rounds</h2>
2424
{% if round_data.results.winner and round_data.results.scores %}
2525
{%- set total_games = round_data.results.scores.values() | sum -%}
2626
{%- set winner = round_data.results.winner -%}
27-
{%- if winner != 'Tie' -%}
27+
{%- if winner != 'Tie' and total_games > 0 -%}
2828
{%- set winner_wins = round_data.results.scores.get(winner, 0) -%}
2929
{%- set ties = round_data.results.scores.get('Tie', 0) -%}
3030
{%- set win_percentage = ((winner_wins + 0.5 * ties) / total_games * 100) | round(1) -%}
@@ -34,13 +34,19 @@ <h2>🎯 Detailed Rounds</h2>
3434
{{- score -}}
3535
{%- if not loop.last -%}-{%- endif -%}
3636
{%- endfor -%})
37-
{%- else -%}
37+
{%- elif winner == 'Tie' and total_games > 0 -%}
3838
- Winner: Tie
3939
{%- if round_data.results.p_value is not none %} (p={{ "%.2f"|format(round_data.results.p_value) }}){% endif %} (
4040
{%- for player, score in round_data.results.scores.items() -%}
4141
{{- score -}}
4242
{%- if not loop.last -%}-{%- endif -%}
4343
{%- endfor -%})
44+
{%- else -%}
45+
- No games played yet (
46+
{%- for player, score in round_data.results.scores.items() -%}
47+
{{- score -}}
48+
{%- if not loop.last -%}-{%- endif -%}
49+
{%- endfor -%})
4450
{% endif %}
4551
{% endif %}
4652
</summary>

0 commit comments

Comments
 (0)