def test_num_bikes(address): db = dbQueries("bikes.db") mdata = db.get_all_names() # change list of tuples to list formatted = [tuple[0] for tuple in mdata] address = address.replace("-", " ") id = db.station_to_ID(address) banking = db.take_credit(id) if banking == True: banking = "Yes" else: banking = "No" count = db.get_valid_real_time_count() # check if there was valid real_time data if count == 0: # fetch data from api data = helpers.request_new_data() db.insert_new_real_time_values(data, True) # fetch all data to send back real_time = db.get_real_time(id) data = real_time[0] return render_template('station.html', Data=data, Address = address, mdata = formatted, Banking = banking )
def test_num_bikes(address): db = dbQueries(path) mdata = db.get_all_names() # change list of tuples to list formatted = [tuple[0] for tuple in mdata] address = address.replace("-", " ") id = db.station_to_ID(address) banking = db.take_credit(id) if banking == True: banking = "Yes" else: banking = "No" count = db.get_valid_real_time_count() # check if there was valid real_time data if count == 0: # fetch data from api data = helpers.request_new_data() db.insert_new_real_time_values(data, True) # fetch all data to send back real_time = db.get_real_time(id) data = real_time[0] return render_template('station.html', Data=data, Address=address, mdata=formatted, Banking=banking)
def real_time_by_station(id): db = dbQueries(path) count = db.get_valid_real_time_count() # check if there was valid real_time data if count == 0: # fetch data from api data = helpers.request_new_data() db.insert_new_real_time_values(data, True) # fetch all data to send back real_time = db.get_real_time(id) # send results back return json.dumps(real_time)
def real_time_by_station(id): db = dbQueries("bikes.db") count = db.get_valid_real_time_count() # check if there was valid real_time data if count == 0: # fetch data from api data = helpers.request_new_data() db.insert_new_real_time_values(data, True) # fetch all data to send back real_time = db.get_real_time(id) # send results back return json.dumps(real_time)
def real_time(): db = dbQueries("bikes.db") count = db.get_valid_real_time_count() # check if there was valid real_time data print(count) if count == 0: # fetch data from api print("no valid data. Fetching new data") data = helpers.request_new_data() db.insert_new_real_time_values(data) # fetch all data to send back real_time = db.get_real_time() db.close_connection() # send results back return json.dumps(real_time)
def real_time(): f = open("/tmp/db.log", "a") f.write("server.py " + path + "\n") f.close() db = dbQueries(path) count = db.get_valid_real_time_count() # check if there was valid real_time data print(count) if count == 0: # fetch data from api print("no valid data. Fetching new data") data = helpers.request_new_data() db.insert_new_real_time_values(data) # fetch all data to send back real_time = db.get_real_time() db.close_connection() # send results back return json.dumps(real_time)
def test_fetch_data(self): data = helpers.request_new_data() assert len(data) > 1