def get_team_score_json(global_config, name, comp, store_json_file=False):
        
    global_config['logger'].debug( 'GET Team %s Score For Competition %s', name, comp )
    
    season = WebCommonUtils.map_comp_to_season(comp)
    session = DbSession.open_db_session(global_config['db_name'] + season)
    
    result = []
    result.append('{ "competition" : "%s", "team" : "%s", ' % (comp,name))
    team_scores = DataModel.getTeamScore(session, name, comp)
    if len(team_scores)==1:
        result.append('"score": "%s" }' % team_scores[0].score)
    else:
        result.append('  "score": [')
        for score in team_scores:
            result.append(score.json())
            result.append(',\n')
        if len(team_scores) > 0:
            result = result[:-1]
        result.append(']}')
        
    json_str = ''.join(result)
    
    if store_json_file is True:
        try:
            FileSync.put( global_config, '%s/EventData/TeamData/team%s_scouting_score.json' % (comp,name), 'text', json_str)
        except:
            raise
        
    session.remove()
    return json_str
def get_team_comp_list(this_comp, team):

    my_config = ScoutingAppMainWebServer.global_config
    complist = list()

    if this_comp == None:
        this_comp = my_config["this_competition"] + my_config["this_season"]
        season = my_config["this_season"]
    else:
        season = map_comp_to_season(this_comp)

    complist.append(this_comp)

    team_complist = WebTeamData.get_team_event_list_from_tba(my_config, team, season)
    if not team_complist:
        session = DbSession.open_db_session(my_config["db_name"] + my_config["this_season"])
        team_scores = DataModel.getTeamScore(session, team)
        for score in team_scores:
            comp = score.competition.upper()
            # currently, the competition season is stored in the database
            # as part of the competition. So, we need to add it for the comparison,
            # but not as we define the complist itself
            if comp != this_comp.upper():
                complist.append(comp)

    else:
        for comp in team_complist:
            if comp.upper() != this_comp.upper():
                complist.append(comp)

    return complist
Exemple #3
0
def get_team_score_page(global_config, name):
        
    global_config['logger'].debug( 'GET Team Score: %s', name )
    
    session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season'])
    
    web.header('Content-Type', 'application/json')
    result = []
    result.append('{ "score": [')
    comp = global_config['this_competition'] + global_config['this_season']
    team_score = DataModel.getTeamScore(session, name, comp)
    for score in team_score:
        result.append(score.json())
        result.append(',\n')
    if len(team_score) > 0:
        result = result[:-1]
    result.append(']}')
    return ''.join(result)
def get_team_score_json(global_config, name, comp):
        
    global_config['logger'].debug( 'GET Team %s Score For Competition %s', name, comp )
    session = DbSession.open_db_session(global_config['db_name'])
    
    web.header('Content-Type', 'application/json')
    result = []
    result.append('{ "competition" : "%s", "team" : "%s", ' % (comp,name))
    team_scores = DataModel.getTeamScore(session, name, comp)
    if len(team_scores)==1:
        result.append('"score": "%s" }' % team_scores[0].score)
    else:
        result.append('  "score": [')
        for score in team_scores:
            result.append(score.json())
            result.append(',\n')
        if len(team_scores) > 0:
            result = result[:-1]
        result.append(']}')
    return ''.join(result)
def get_team_comp_list(this_comp, team):
    
    my_config = ScoutingAppMainWebServer.global_config
    complist = list()
    
    if this_comp == None:
        this_comp = my_config['this_competition'] + my_config['this_season']
        
    complist.append(this_comp)
    
    session = DbSession.open_db_session(my_config['db_name'])
    team_scores = DataModel.getTeamScore(session, team)
    for score in team_scores:
        comp = score.competition
        # currently, the competition season is stored in the database
        # as part of the competition. So, we need to add it for the comparison,
        # but not as we define the complist itself
        if comp != this_comp:
            complist.append(comp)
    return complist