def handle(self, *args, **kwargs): if not os.path.exists(kwargs["root"]): os.makedirs(kwargs["root"]) print('Calculating ranks') teams = [self.make_team_row(team) for team in tab_logic.rank_teams()] nov_teams = [ self.make_team_row(team) for team in tab_logic.rank_nov_teams() ] debaters = [ self.make_debater_row(deb) for deb in tab_logic.rank_speakers() ] nov_debaters = [ self.make_debater_row(deb) for deb in tab_logic.rank_nov_speakers() ] print('Writing to csv') self.write_to_csv(os.path.join(kwargs["root"], kwargs["team_file"]), self.TEAM_ROWS, teams) self.write_to_csv( os.path.join(kwargs["root"], kwargs["nov_team_file"]), self.TEAM_ROWS, nov_teams) self.write_to_csv(os.path.join(kwargs["root"], kwargs["debater_file"]), self.DEBATER_ROWS, debaters) self.write_to_csv( os.path.join(kwargs["root"], kwargs["nov_debater_file"]), self.DEBATER_ROWS, nov_debaters) print('Done!')
def rank_debaters(request): speakers = tab_logic.rank_speakers() debaters = [(s.debater, s.speaks, s.ranks, s.debater.team_set.first()) for s in speakers] nov_debaters = filter(lambda s: s[0].novice_status == Debater.NOVICE, debaters) return render(request, 'tab/rank_debaters_component.html', {'debaters': debaters, 'nov_debaters' : nov_debaters, 'title': "Speaker Rankings"})
def rank_debaters(request): speakers = tab_logic.rank_speakers() debaters = [(s.debater, s.speaks, s.ranks, s.debater.team_set.first()) for s in speakers] nov_debaters = filter(lambda s: s[0].novice_status == Debater.NOVICE, debaters) return render(request, 'rank_debaters_component.html', {'debaters': debaters, 'nov_debaters' : nov_debaters, 'title': "Speaker Rankings"})
def rank_debaters(request): speakers = tab_logic.rank_speakers() debaters = [(s, tab_logic.tot_speaks_deb(s), tab_logic.tot_ranks_deb(s), tab_logic.deb_team(s)) for s in speakers] nov_speakers = tab_logic.rank_nov_speakers() nov_debaters = [ (s, tab_logic.tot_speaks_deb(s), tab_logic.tot_ranks_deb(s), tab_logic.deb_team(s)) for s in nov_speakers ] return render_to_response( "rank_debaters_component.html", {"debaters": debaters, "nov_debaters": nov_debaters, "title": "Speaker Rankings"}, context_instance=RequestContext(request), )
def rank_debaters(request): speakers = tab_logic.rank_speakers() debaters = [(s, tab_logic.tot_speaks_deb(s), tab_logic.tot_ranks_deb(s), tab_logic.deb_team(s)) for s in speakers] nov_speakers = tab_logic.rank_nov_speakers() nov_debaters = [(s, tab_logic.tot_speaks_deb(s), tab_logic.tot_ranks_deb(s), tab_logic.deb_team(s)) for s in nov_speakers] return render_to_response('rank_debaters_component.html', { 'debaters': debaters, 'nov_debaters': nov_debaters, 'title': "Speaker Rankings" }, context_instance=RequestContext(request))
def handle(self, *args, **kwargs): if not os.path.exists(kwargs["root"]): os.makedirs(kwargs["root"]) print('Calculating ranks') teams = [ self.make_team_row(team) for team in tab_logic.rank_teams() ] nov_teams = [ self.make_team_row(team) for team in tab_logic.rank_nov_teams() ] debaters = [ self.make_debater_row(deb) for deb in tab_logic.rank_speakers() ] nov_debaters = [ self.make_debater_row(deb) for deb in tab_logic.rank_nov_speakers() ] print('Writing to csv') self.write_to_csv(os.path.join(kwargs["root"], kwargs["team_file"]), self.TEAM_ROWS, teams) self.write_to_csv(os.path.join(kwargs["root"], kwargs["nov_team_file"]), self.TEAM_ROWS, nov_teams) self.write_to_csv(os.path.join(kwargs["root"], kwargs["debater_file"]), self.DEBATER_ROWS, debaters) self.write_to_csv(os.path.join(kwargs["root"], kwargs["nov_debater_file"]), self.DEBATER_ROWS, nov_debaters) print('Done!')
def get_speaker_rankings(request): speakers = tab_logic.rank_speakers() debaters = [] for i, debater_stats in enumerate(speakers): tiebreaker = "N/A" if i != len(speakers) - 1: next_debater_stats = speakers[i + 1] tiebreaker_stat = debater_stats.get_tiebreaker(next_debater_stats) if tiebreaker_stat is not None: tiebreaker = tiebreaker_stat.name else: tiebreaker = "Tie not broken" debaters.append((debater_stats.debater, debater_stats[rankings.SPEAKS], debater_stats[rankings.RANKS], debater_stats.debater.team(), tiebreaker)) nov_debaters = list(filter(lambda s: s[0].novice_status == Debater.NOVICE, debaters)) return debaters, nov_debaters