示例#1
0
def save_match_in_db(matches_json):
    matches = []

    for match in matches_json['rows']:
        matches.append({
            '_match_pk': match['match_id'],
            '_match_seq_num': match['match_seq_num'],
            '_game_mode': match['game_mode'],
            '_dire_score': match['dire_score'],
            '_first_blood_time': match['first_blood_time'],
            '_human_players': match['human_players'],
            '_radiant_team': match['radiant_team'],
            '_dire_team': match['dire_team'],
            '_radiant_team_bans': match['radiant_team_bans'],
            '_dire_team_bans': match['dire_team_bans']
        })

    update_statement = pro_match.update() \
        .where(pro_match.c.match_pk == bindparam('_match_pk')) \
        .values({
        'match_seq_num': bindparam('_match_seq_num'),
        'game_mode': bindparam('_game_mode'),
        'dire_score': bindparam('_dire_score'),
        'first_blood_time': bindparam('_first_blood_time'),
        'human_players': bindparam('_human_players'),
        'radiant_team': bindparam('_radiant_team'),
        'dire_team': bindparam('_dire_team'),
        'radiant_team_bans': bindparam('_radiant_team_bans'),
        'dire_team_bans': bindparam('_dire_team_bans')
    })

    return conn.execute(update_statement, matches)
示例#2
0
def get_match_pk_not_downloaded():
    sel = select([pro_match.c.match_pk, pro_match.c.replay_url]).where(
        and_(pro_match.c.game_mode == 2, pro_match.c.replay_url != None,
             pro_match.c.downloaded_replay == None)).order_by(
                 pro_match.c.match_pk.desc())
    res = conn.execute(sel)
    return res.fetchone()
def get_all_public_picks(limit, offset):
    sel_radiant = select([public_match.c.radiant_team.label('heroes')
                          ]).where(public_match.c.radiant_team != None)
    sel_dire = select([public_match.c.dire_team.label('heroes')
                       ]).where(public_match.c.dire_team != None)
    res = conn.execute(
        sel_radiant.union_all(sel_dire).limit(limit).offset(offset))
    return res.fetchall()
示例#4
0
def save_match_in_db(matches_json, match_pk):
    replay_url = 'MISSING'

    if 'replay_url' in matches_json:
        replay_url = matches_json['replay_url']

    update_statement = pro_match.update().where(
        pro_match.c.match_pk == match_pk).values(replay_url=replay_url)
    return conn.execute(update_statement)
示例#5
0
def get_last_match_pk_to_handle():
    sel = select([
        pro_match.c.match_pk
    ]).where(
        and_(
            pro_match.c.game_mode == 2,
            pro_match.c.downloaded_replay == True,
            pro_match.c.parse_success == None
        )
    ).order_by(
        pro_match.c.match_pk.desc()
    )

    res = conn.execute(sel)
    return res.fetchone()
def save_match_in_db(matches_json):
    matches = []

    for match in matches_json:
        matches.append({
            'match_pk': match['match_id'],
            'radiant_win': match['radiant_win'],
            'duration': match['duration'],
            'radiant_team_id': match['radiant_team_id'],
            'radiant_name': match['radiant_name'],
            'dire_team_id': match['dire_team_id'],
            'dire_name': match['dire_name'],
            'radiant_score': match['radiant_score'],
            'dire_score': match['dire_score'],
            'start_time': match['start_time']
        })

    return conn.execute(pro_match.insert(), matches)
def db_log(module_name, error_message):
    ins = error_log.insert().values(module_name=module_name,
                                    error_message=json.dumps(error_message))
    return conn.execute(ins)
示例#8
0
def save_match_in_db(match_pk, success):
    update_statement = pro_match.update().where(
        pro_match.c.match_pk == match_pk).values(downloaded_replay=success)
    return conn.execute(update_statement)
示例#9
0
def get_last_match_pk_where_seq_num_is_null():
    sel = select([pro_match.c.match_pk]) \
        .where(pro_match.c.match_seq_num == None) \
        .order_by(pro_match.c.match_pk)
    res = conn.execute(sel)
    return res.fetchone()
def get_last_match_pk():
    sel = select([pro_match.c.match_pk]).order_by(pro_match.c.match_pk)
    res = conn.execute(sel)
    return res.fetchone()
def get_all_heroes():
    sel = select([func.count()]).select_from(public_match)
    res = conn.execute(sel)
    return res.fetchone()
示例#12
0
def get_last_match_pk_where_url_is_null():
    sel = select([pro_match.c.match_pk
                  ]).where(pro_match.c.replay_url == None).order_by(
                      pro_match.c.match_pk.desc())
    res = conn.execute(sel)
    return res.fetchone()