def api_get_route_trips_and_ticketing_analysis(start_data,end_data):
    start_date = datetime.datetime.strptime(start_data, '%Y-%m-%d')
    end_date = datetime.datetime.strptime(end_data, '%Y-%m-%d')

    answer = funcoes_aux.get_route_trips_and_ticketing(start_date, end_date)

    return funcoes_aux.function_cors(answer)
def api_get_route_trips_analysis(start_data,end_data):
    answer = "rota,data,hora_inicio,hora_fim,duracao,numero_onibus,hora_inicio_tb,hora_fim_tb,duracao_tb,del,operador,empresa,linha,pareado\n"
    start_date = datetime.datetime.strptime(start_data, '%Y-%m-%d')
    end_date = datetime.datetime.strptime(end_data, '%Y-%m-%d')
    day_count = (end_date - start_date).days + 1

    route_list = funcoes_aux.get_all_routes()

    for route in route_list:
        route_aux = route["rota"].encode('utf-8')
        for single_date in (start_date + datetime.timedelta(n) for n in range(day_count)):
            data = datetime.datetime.strftime(single_date, '%Y-%m-%d') 
            travels = funcoes_aux.get_travels_analysis(data,route_aux)
            frame_schedules = funcoes_aux.get_frame_schedules(data,route_aux)
            for travel in funcoes_aux.create_json_final_analysis(travels,frame_schedules,data,route_aux):
                answer= answer+ travel
    return funcoes_aux.function_cors(answer)
def api_get_travels(data,bus):
    return funcoes_aux.function_cors(funcoes_aux.montaJson(funcoes_aux.get_travels(data,bus)))
def api_get_frame_schedules(data,bus):
    return funcoes_aux.function_cors(funcoes_aux.montaJson(funcoes_aux.get_frame_schedules(data,bus)))
def api_get_valid_routes():
    return funcoes_aux.function_cors(funcoes_aux.get_valid_routes())