Coverage for src/season_battle_info.py: 0%

21 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-03 19:06 +0000

1import numpy as np 

2import pandas as pd 

3 

4from src.api import spl 

5from src.utils import progress_util 

6 

7 

8def get_season_battles(account_name, store_df, mode, current_season_id): 

9 if not (store_df.empty or 

10 store_df.loc[store_df.player == account_name].empty): 

11 next_season = store_df.loc[store_df.player == account_name].season.max() + 1 

12 season_array = np.arange(next_season, current_season_id) 

13 else: 

14 season_array = np.arange(1, current_season_id) 

15 

16 if len(season_array) > 0: 

17 for season_id in season_array: 

18 progress_util.update_season_msg("Gathering (" + str(account_name) + ", " 

19 + str(mode.value) + 

20 ") battle info for season :" + str(season_id)) 

21 result = spl.get_leaderboard_with_player_season(account_name, season_id, mode) 

22 if 'rank' in result: 

23 result_df = pd.DataFrame(result, index=[0]) 

24 result_df = result_df.where(pd.notna(result_df), None) 

25 store_df = pd.concat([store_df, result_df], 

26 ignore_index=True) 

27 else: 

28 store_df = pd.concat([store_df, 

29 pd.DataFrame({'player': account_name, 'season': season_id}, index=[0])], 

30 ignore_index=True) 

31 else: 

32 progress_util.update_season_msg("No new season battle info found for: " + str(account_name)) 

33 

34 progress_util.update_season_msg("Gathering '" + str(account_name) + ", " 

35 + str(mode.value) + 

36 "' battle info done..") 

37 

38 return store_df