Beispiel #1
0
 def test_all_rates(self):
     players_data = self.players_data()
     result = RatingCalculator.enhance_data(players_data)
     first_player = result[0]
     expected = {
         'total_resources_earned': 16000,
         'seven_day_resources_earned': 320,
         'thirty_day_resources_earned': 320,
         'total_resources_earned_rate': 's9',
         'seven_day_resources_earned_rate': 's9',
         'thirty_day_resources_earned_rate': 's9'
     }
     self.assertEqual(expected, first_player)
     second_player = result[1]
     expected = {
         'total_resources_earned': 1000,
         'seven_day_resources_earned': 150,
         'thirty_day_resources_earned': 200,
         'total_resources_earned_rate': 's3',
         'seven_day_resources_earned_rate': 's6',
         'thirty_day_resources_earned_rate': 's3'
     }
     self.assertEqual(expected, second_player)
     fourth_player = result[3]
     expected = {
         'total_resources_earned': 500,
         'seven_day_resources_earned': 30,
         'thirty_day_resources_earned': 30,
         'total_resources_earned_rate': 's2',
         'seven_day_resources_earned_rate': 's2',
         'thirty_day_resources_earned_rate': 's2'
     }
     self.assertEqual(expected, fourth_player)
 def test_all_rates(self):
     players_data = self.players_data()
     result = RatingCalculator.enhance_data(players_data)
     first_player = result[0]
     expected = {'total_resources_earned': 16000,
                 'seven_day_resources_earned': 320,
                 'thirty_day_resources_earned': 320,
                 'total_resources_earned_rate': 's9',
                 'seven_day_resources_earned_rate': 's9',
                 'thirty_day_resources_earned_rate': 's9'}
     self.assertEqual(expected, first_player)
     second_player = result[1]
     expected = {'total_resources_earned': 1000,
                 'seven_day_resources_earned': 150,
                 'thirty_day_resources_earned': 200,
                 'total_resources_earned_rate': 's3',
                 'seven_day_resources_earned_rate': 's6',
                 'thirty_day_resources_earned_rate': 's3'}
     self.assertEqual(expected, second_player)
     fourth_player = result[3]
     expected = {'total_resources_earned': 500,
                 'seven_day_resources_earned': 30,
                 'thirty_day_resources_earned': 30,
                 'total_resources_earned_rate': 's2',
                 'seven_day_resources_earned_rate': 's2',
                 'thirty_day_resources_earned_rate': 's2'}
     self.assertEqual(expected, fourth_player)
Beispiel #3
0
def clan_stats(clan_id):
    logger.info('Display Stats for clan: %s' % clan_id)
    start_time = time.time()
    players_data, clan_details = ClanController().get_clan_stats(connect_db(), clan_id)
    enhanced_players_data = RatingCalculator.enhance_data(players_data)
    end_time = time.time()
    logger.info('Display Stats Elapsed Time: %s' % str(end_time - start_time))
    return render_template('player_stats.html', players_data=enhanced_players_data, clan_details=clan_details)