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

Merge branch 'develop' into 'master'

Develop

See merge request namibsun/python/bundesliga-tippspiel!21
parents 9a50acdf 6365e3c6
Loading
Loading
Loading
Loading
+2 −0
Changes for CHANGELOG: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
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:
+14 −1
Changes for bundesliga_tippspiel/test/utils/TestStats.py: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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()
+3 −0
Changes for bundesliga_tippspiel/utils/stats.py: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -134,7 +134,10 @@ def create_participation_ranking(bets: Optional[List[Bet]] = None) \

    ranking = []
    for user, betcount in participation_stats.items():
        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 −1
Changes for version: 1 added line, 1 removed line.
Original line number Diff line number Diff line
1.0.0
 No newline at end of file
1.0.1
 No newline at end of file