Example #1
0
    def __init__(
            self,
            global_data,
            p1_league_codes,
            p2_league_codes,
            ):
        self.p1_league_codes = set(p1_league_codes)
        self.p2_league_codes = set(p2_league_codes)
        player_data = global_data.get_player_data_by_bins(
            CFNLeagueCache.convert_leagues_to_bins(self.p1_league_codes),
            CFNLeagueCache.convert_leagues_to_bins(self.p2_league_codes),
        )
        super(GlobalViewModel, self).__init__(player_data)
        self._analyze_round_data()

        self.name = "CHARACTER MATCHUPS BY LEAGUE"
        self.updated_date = convert_dt_to_nyc(
            get_latest_player_updated_at()
        )
        self.total_match_count = self.data.game_count // 2

        self.character_order = list(map(
            CharacterViewModel, cfn_constants.CHARACTER_ORDER
        ))
        all_league_codes = CFNLeagueCache.all_league_codes()
        self.p1_all_leagues = self.p1_league_codes == all_league_codes
        self.p2_all_leagues = self.p2_league_codes == all_league_codes
Example #2
0
 def test_leagues_unique(self):
     bounds = set()
     for league in CFNLeagueCache.leagues():
         self.assertNotIn(league.lower_bound, bounds)
         bounds.add(league.lower_bound)
         self.assertNotIn(league.upper_bound, bounds)
         bounds.add(league.upper_bound)
     bins = set()
     for league in CFNLeagueCache.leagues():
         for league_bin in league.bins:
             self.assertNotIn(league_bin, bins)
             bins.add(league_bin)
Example #3
0
 def get_by_leagues(self, p1_league_codes, p2_league_codes):
     p1_league_codes = p1_league_codes or CFNLeagueCache.all_league_codes()
     p2_league_codes = p2_league_codes or CFNLeagueCache.all_league_codes()
     for gvm in self.cached_vms:
         if gvm.bins_match(p1_league_codes, p2_league_codes):
             return gvm
     # else if no match
     new_global_view_model = GlobalViewModel(
         self.global_data,
         p1_league_codes,
         p2_league_codes,
     )
     self.cached_vms.append(new_global_view_model)
     return new_global_view_model
Example #4
0
 def get_by_leagues(self, p1_league_codes, p2_league_codes):
     p1_league_codes = p1_league_codes or CFNLeagueCache.all_league_codes()
     p2_league_codes = p2_league_codes or CFNLeagueCache.all_league_codes()
     for gvm in self.cached_vms:
         if gvm.bins_match(p1_league_codes, p2_league_codes):
             return gvm
     # else if no match
     new_global_view_model = GlobalViewModel(
         self.global_data,
         p1_league_codes,
         p2_league_codes,
     )
     self.cached_vms.append(new_global_view_model)
     return new_global_view_model
Example #5
0
 def __init__(self):
     self.player_rankings = sorted(
         get_player_rankings(),
         key=lambda pr: pr.placement,
     )
     self.updated_time = convert_dt_to_nyc(
         self.player_rankings[0].created_at)
     for pr in self.player_rankings:
         pr.league = CFNLeagueCache.from_league_points(pr.league_points)
         pr.favorite_character = CharacterViewModel(
             pr.favorite_character_id)
         pr.most_used_character = CharacterViewModel(
             pr.most_used_character_id)
Example #6
0
    def __init__(
        self,
        global_data,
        p1_league_codes,
        p2_league_codes,
    ):
        self.p1_league_codes = set(p1_league_codes)
        self.p2_league_codes = set(p2_league_codes)
        player_data = global_data.get_player_data_by_bins(
            CFNLeagueCache.convert_leagues_to_bins(self.p1_league_codes),
            CFNLeagueCache.convert_leagues_to_bins(self.p2_league_codes),
        )
        super(GlobalViewModel, self).__init__(player_data)
        self._analyze_round_data()

        self.name = "CHARACTER MATCHUPS BY LEAGUE"
        self.updated_date = convert_dt_to_nyc(get_latest_player_updated_at())
        self.total_match_count = self.data.game_count // 2

        self.character_order = list(
            map(CharacterViewModel, cfn_constants.CHARACTER_ORDER))
        all_league_codes = CFNLeagueCache.all_league_codes()
        self.p1_all_leagues = self.p1_league_codes == all_league_codes
        self.p2_all_leagues = self.p2_league_codes == all_league_codes
Example #7
0
 def __init__(self):
     self.player_rankings = sorted(
         get_player_rankings(),
         key=lambda pr: pr.placement,
     )
     self.updated_time = convert_dt_to_nyc(
         self.player_rankings[0].created_at
     )
     for pr in self.player_rankings:
         pr.league = CFNLeagueCache.from_league_points(pr.league_points)
         pr.favorite_character = CharacterViewModel(
             pr.favorite_character_id
         )
         pr.most_used_character = CharacterViewModel(
             pr.most_used_character_id
         )
Example #8
0
 def test_leagues_declared(self):
     self.assertEqual(14, len(CFNLeagueCache.leagues()))