src/server/server.py
def findBestValues(node, node_index):
    ''' Search race history for best tuning values '''

    # get commonly used values
    heat = Database.Heat.query.get(RACE.current_heat)
    pilot = Database.HeatNode.query.filter_by(heat_id=RACE.current_heat, node_index=node_index).first().pilot_id
    current_class = heat.class_id

    # test for disabled node
    if pilot is Database.PILOT_ID_NONE or node.frequency is RHUtils.FREQUENCY_ID_NONE:
        logger.debug('Node {0} calibration: skipping disabled node'.format(node.index+1))
        return {
            'enter_at_level': node.enter_at_level,
            'exit_at_level': node.exit_at_level
        }

    # test for same heat, same node
    race_query = Database.SavedRaceMeta.query.filter_by(heat_id=heat.id).order_by(-Database.SavedRaceMeta.id).first()

    if race_query:
        pilotrace_query = Database.SavedPilotRace.query.filter_by(race_id=race_query.id, pilot_id=pilot).order_by(-Database.SavedPilotRace.id).first()
        if pilotrace_query:
            logger.debug('Node {0} calibration: found same pilot+node in same heat'.format(node.index+1))
            return {
                'enter_at_level': pilotrace_query.enter_at,
                'exit_at_level': pilotrace_query.exit_at
            }

    # test for same class, same pilot, same node
    race_query = Database.SavedRaceMeta.query.filter_by(class_id=current_class).order_by(-Database.SavedRaceMeta.id).first()
    if race_query:
        pilotrace_query = Database.SavedPilotRace.query.filter_by(race_id=race_query.id, node_index=node_index, pilot_id=pilot).order_by(-Database.SavedPilotRace.id).first()
        if pilotrace_query:
            logger.debug('Node {0} calibration: found same pilot+node in other heat with same class'.format(node.index+1))
            return {
                'enter_at_level': pilotrace_query.enter_at,
                'exit_at_level': pilotrace_query.exit_at
            }

    # test for same pilot, same node
    pilotrace_query = Database.SavedPilotRace.query.filter_by(node_index=node_index, pilot_id=pilot).order_by(-Database.SavedPilotRace.id).first()
    if pilotrace_query:
        logger.debug('Node {0} calibration: found same pilot+node in other heat with other class'.format(node.index+1))
        return {
            'enter_at_level': pilotrace_query.enter_at,
            'exit_at_level': pilotrace_query.exit_at
        }

    # test for same node
    pilotrace_query = Database.SavedPilotRace.query.filter_by(node_index=node_index).order_by(-Database.SavedPilotRace.id).first()
    if pilotrace_query:
        logger.debug('Node {0} calibration: found same node in other heat'.format(node.index+1))
        return {
            'enter_at_level': pilotrace_query.enter_at,
            'exit_at_level': pilotrace_query.exit_at
        }

    # fallback
    logger.debug('Node {0} calibration: no calibration hints found, no change'.format(node.index+1))
    return {
        'enter_at_level': node.enter_at_level,
        'exit_at_level': node.exit_at_level
    }
 Search race history for best tuning values 
Search race history for best tuning values
Search race history for best tuning values
def findBestValues(node, node_index):
    heat = Database.Heat.query.get(RACE.current_heat)
    pilot = Database.HeatNode.query.filter_by(heat_id=RACE.current_heat, node_index=node_index).first().pilot_id
    current_class = heat.class_id
    if pilot is Database.PILOT_ID_NONE or node.frequency is RHUtils.FREQUENCY_ID_NONE:
        logger.debug('Node {0} calibration: skipping disabled node'.format(node.index+1))
        return {
            'enter_at_level': node.enter_at_level,
            'exit_at_level': node.exit_at_level
        }
    race_query = Database.SavedRaceMeta.query.filter_by(heat_id=heat.id).order_by(-Database.SavedRaceMeta.id).first()
    if race_query:
        pilotrace_query = Database.SavedPilotRace.query.filter_by(race_id=race_query.id, pilot_id=pilot).order_by(-Database.SavedPilotRace.id).first()
        if pilotrace_query:
            logger.debug('Node {0} calibration: found same pilot+node in same heat'.format(node.index+1))
            return {
                'enter_at_level': pilotrace_query.enter_at,
                'exit_at_level': pilotrace_query.exit_at
            }
    race_query = Database.SavedRaceMeta.query.filter_by(class_id=current_class).order_by(-Database.SavedRaceMeta.id).first()
    if race_query:
        pilotrace_query = Database.SavedPilotRace.query.filter_by(race_id=race_query.id, node_index=node_index, pilot_id=pilot).order_by(-Database.SavedPilotRace.id).first()
        if pilotrace_query:
            logger.debug('Node {0} calibration: found same pilot+node in other heat with same class'.format(node.index+1))
            return {
                'enter_at_level': pilotrace_query.enter_at,
                'exit_at_level': pilotrace_query.exit_at
            }
    pilotrace_query = Database.SavedPilotRace.query.filter_by(node_index=node_index, pilot_id=pilot).order_by(-Database.SavedPilotRace.id).first()
    if pilotrace_query:
        logger.debug('Node {0} calibration: found same pilot+node in other heat with other class'.format(node.index+1))
        return {
            'enter_at_level': pilotrace_query.enter_at,
            'exit_at_level': pilotrace_query.exit_at
        }
    pilotrace_query = Database.SavedPilotRace.query.filter_by(node_index=node_index).order_by(-Database.SavedPilotRace.id).first()
    if pilotrace_query:
        logger.debug('Node {0} calibration: found same node in other heat'.format(node.index+1))
        return {
            'enter_at_level': pilotrace_query.enter_at,
            'exit_at_level': pilotrace_query.exit_at
        }
    logger.debug('Node {0} calibration: no calibration hints found, no change'.format(node.index+1))
    return {
        'enter_at_level': node.enter_at_level,
        'exit_at_level': node.exit_at_level
    }
def findBestValues ( node , node_index ) : heat = Database . Heat . query . get ( RACE . current_heat ) pilot = Database . HeatNode . query . filter_by ( heat_id = RACE . current_heat , node_index = node_index ) . first ( ) . pilot_id current_class = heat . class_id if pilot is Database . PILOT_ID_NONE or node . frequency is RHUtils . FREQUENCY_ID_NONE : logger . debug ( 'Node {0} calibration: skipping disabled node' . format ( node . index + 1 ) ) return { 'enter_at_level' : node . enter_at_level , 'exit_at_level' : node . exit_at_level } race_query = Database . SavedRaceMeta . query . filter_by ( heat_id = heat . id ) . order_by ( - Database . SavedRaceMeta . id ) . first ( ) if race_query : pilotrace_query = Database . SavedPilotRace . query . filter_by ( race_id = race_query . id , pilot_id = pilot ) . order_by ( - Database . SavedPilotRace . id ) . first ( ) if pilotrace_query : logger . debug ( 'Node {0} calibration: found same pilot+node in same heat' . format ( node . index + 1 ) ) return { 'enter_at_level' : pilotrace_query . enter_at , 'exit_at_level' : pilotrace_query . exit_at } race_query = Database . SavedRaceMeta . query . filter_by ( class_id = current_class ) . order_by ( - Database . SavedRaceMeta . id ) . first ( ) if race_query : pilotrace_query = Database . SavedPilotRace . query . filter_by ( race_id = race_query . id , node_index = node_index , pilot_id = pilot ) . order_by ( - Database . SavedPilotRace . id ) . first ( ) if pilotrace_query : logger . debug ( 'Node {0} calibration: found same pilot+node in other heat with same class' . format ( node . index + 1 ) ) return { 'enter_at_level' : pilotrace_query . enter_at , 'exit_at_level' : pilotrace_query . exit_at } pilotrace_query = Database . SavedPilotRace . query . filter_by ( node_index = node_index , pilot_id = pilot ) . order_by ( - Database . SavedPilotRace . id ) . first ( ) if pilotrace_query : logger . debug ( 'Node {0} calibration: found same pilot+node in other heat with other class' . format ( node . index + 1 ) ) return { 'enter_at_level' : pilotrace_query . enter_at , 'exit_at_level' : pilotrace_query . exit_at } pilotrace_query = Database . SavedPilotRace . query . filter_by ( node_index = node_index ) . order_by ( - Database . SavedPilotRace . id ) . first ( ) if pilotrace_query : logger . debug ( 'Node {0} calibration: found same node in other heat' . format ( node . index + 1 ) ) return { 'enter_at_level' : pilotrace_query . enter_at , 'exit_at_level' : pilotrace_query . exit_at } logger . debug ( 'Node {0} calibration: no calibration hints found, no change' . format ( node . index + 1 ) ) return { 'enter_at_level' : node . enter_at_level , 'exit_at_level' : node . exit_at_level }
Search race history for best tuning values
Search race history for best tuning values
''' Search race history for best tuning values ''' # get commonly used values # test for disabled node # test for same heat, same node # test for same class, same pilot, same node # test for same pilot, same node # test for same node # fallback
node
node_index