def main(): parser = OptionParser() parser.add_option('-w', '--week', dest='week', help='enter week to scrape stats for') (options, args) = parser.parse_args() matchups = auctionDb.getWeekMatchups(options.week) scoreMap = auctionDb.getMatchupScores(options.week) for index in range(len(matchups)/2): team1 = matchups[index * 2] team2 = matchups[index * 2 + 1] if team1['user_id'] in scoreMap: team1['score'] = scoreMap[team1['user_id']] else: team1['score'] = 0 if team2['user_id'] in scoreMap: team2['score'] = scoreMap[team2['user_id']] else: team2['score'] = 0 if team1['score'] > team2['score']: auctionDb.addUserResult(team1['user_id'], 'win', team1['score']) auctionDb.addUserResult(team2['user_id'], 'loss', team2['score']) elif team2['score'] > team1['score']: auctionDb.addUserResult(team1['user_id'], 'loss', team1['score']) auctionDb.addUserResult(team2['user_id'], 'win', team2['score']) else: auctionDb.addUserResult(team1['user_id'], 'tie', team1['score']) auctionDb.addUserResult(team2['user_id'], 'tie', team2['score'])
def GET(self): session = web.config._session filters = web.input(week=None) if filters.week == None: filters.week = auctionDb.getCurrentWeek() else: filters.week = int(filters.week) weekMatchups = auctionDb.getWeekMatchups(filters.week) matchupScores = auctionDb.getMatchupScores(filters.week) for matchup in weekMatchups: if matchup['user_id'] in matchupScores.keys(): matchup['total_pts'] = matchupScores[matchup['user_id']] else: matchup['total_pts'] = 0 return str(getTemplateSystem(session, filters).scoreboard(weekMatchups))