9
9
10
10
from models import Player , PlayerGame , Game , Season , Zone , PlayerSeason , Map
11
11
from src .log_utils import create_logger
12
- from src .utils import CustomJSONEncoder , RANKS , calculate_points
12
+ from src .utils import CustomJSONEncoder , RANKS , distribute_points
13
13
from src .threads .abstract_thread import AbstractThread
14
14
15
15
logger = create_logger ("update_big_queries" )
16
16
17
17
18
18
def get_countries_leaderboard (season_id ):
19
19
total_players = 1000
20
+ points_repartition = distribute_points (max_points = 10000 , num_people = total_players )
20
21
player_seasons = (
21
22
PlayerSeason .select (
22
23
Player .uuid ,
@@ -37,7 +38,10 @@ def get_countries_leaderboard(season_id):
37
38
objs = [o for o in player_seasons ]
38
39
countries = {}
39
40
for o in objs :
40
- computed_points = calculate_points (o ["rank" ], total_players = total_players )
41
+ if o ["rank" ] > len (points_repartition ):
42
+ computed_points = 0
43
+ else :
44
+ computed_points = int (points_repartition [o ["rank" ] - 1 ])
41
45
if not o ["country" ] in countries :
42
46
countries [o ["country" ]] = {
43
47
"name" : o ["name" ],
@@ -62,6 +66,7 @@ def get_countries_leaderboard(season_id):
62
66
63
67
def get_clubs_leaderboard (season_id ):
64
68
total_players = 1000
69
+ points_repartition = distribute_points (max_points = 10000 , num_people = total_players )
65
70
player_seasons = (
66
71
PlayerSeason .select (
67
72
Player .uuid ,
@@ -78,7 +83,10 @@ def get_clubs_leaderboard(season_id):
78
83
objs = [o for o in player_seasons ]
79
84
club_tags = {}
80
85
for o in objs :
81
- computed_points = calculate_points (o ["rank" ], total_players = total_players )
86
+ if o ["rank" ] > len (points_repartition ):
87
+ computed_points = 0
88
+ else :
89
+ computed_points = int (points_repartition [o ["rank" ] - 1 ])
82
90
if not o ["club_tag" ] in club_tags :
83
91
club_tags [o ["club_tag" ]] = {"name" : o ["club_tag" ], "points" : 0 , "count" : 0 }
84
92
if club_tags [o ["club_tag" ]]["count" ] < 10 :
0 commit comments