Commit 832176f3 authored by Hermann Krumrey's avatar Hermann Krumrey

Merge branch 'develop' into 'master'

Develop

See merge request namibsun/python/bundesliga-tippspiel!21
parents 9a50acdf 6365e3c6
V 1.0.1:
- Fixed issues with statistics page when season hasn't started yet
V 1.0.0:
- Prepared code for bundesliga 2019/20 season
V 0.20.1:
......
......@@ -22,7 +22,8 @@ from bundesliga_tippspiel.models.match_data.Match import Match
# noinspection PyProtectedMember
from bundesliga_tippspiel.test.TestFramework import _TestFramework
from bundesliga_tippspiel.utils.stats import get_team_points_data, \
generate_team_points_table, get_total_points_per_team
generate_team_points_table, get_total_points_per_team, \
create_participation_ranking, create_point_average_ranking
class TestStats(_TestFramework):
......@@ -73,3 +74,15 @@ class TestStats(_TestFramework):
self.assertNotEqual(table_two, table_all)
self.assertEqual(table_all[0][1], total_points)
def test_rankings_before_season(self):
"""
Tests the generation of rankings before the season has started
:return: None
"""
self.generate_sample_user(True)
try:
create_point_average_ranking()
create_participation_ranking()
except ZeroDivisionError:
self.fail()
......@@ -134,7 +134,10 @@ def create_participation_ranking(bets: Optional[List[Bet]] = None) \
ranking = []
for user, betcount in participation_stats.items():
percentage = int((betcount / len(matches)) * 100)
try:
percentage = int((betcount / len(matches)) * 100)
except ZeroDivisionError:
percentage = 100.0
ranking.append((user, percentage))
ranking.sort(key=lambda x: x[1], reverse=True)
......
1.0.0
\ No newline at end of file
1.0.1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment