Ejemplo n.º 1
0
def daily_avg_byID(ID,day):
    x = (livepopulartimes.get_populartimes_by_PlaceID(GOOGLE_MAPS_API_KEY,ID ))
    daily_PT_List = x["populartimes"][day]["data"]
    avg = sum(daily_PT_List) / len(daily_PT_List)
    avg = round(avg,1)
    day = x["populartimes"][day]["name"]
    data = {day:avg}
    return data
Ejemplo n.º 2
0
def weekly_avg_byID(ID):
    x = (livepopulartimes.get_populartimes_by_PlaceID(GOOGLE_MAPS_API_KEY,ID ))
    x = x["populartimes"]
    l = []
    for i in x:
        daily_List = i["data"]
        avg = sum(daily_List) / len(daily_List)
        avg = round(avg,3)
        l.append(avg)
    weekly_avg = sum(l) / len(l)
    weekly_avg= round(weekly_avg,1)
    return weekly_avg
Ejemplo n.º 3
0
def getPopularTimes(id):
    command = "SELECT * FROM places WHERE place_id = %s"
    values = (id,)
    result_db = app.database.fetch(command, values)
    if (len(result_db) == 0):
        print(os.getenv("GOOGLE_API_KEY"))
        result = livepopulartimes.get_populartimes_by_PlaceID(os.getenv("GOOGLE_API_KEY"), id)
        
        json_string = json.dumps(result)
        command = "INSERT INTO places (place_id, popular_times_response) VALUES (%s, %s)"
        values = (id, json_string)
        app.database.execute(command, values,)
        return result
    return json.loads(result_db[0][1])
Ejemplo n.º 4
0
def get_place_popular_moments(key, place_id):
    popular_moments = livepopulartimes.get_populartimes_by_PlaceID(
        key, place_id)
    return popular_moments
Ejemplo n.º 5
0
def get_popular_times(placeID):
    return livepopulartimes.get_populartimes_by_PlaceID(
        constants.GOOGLE_API_KEY, placeID)
Ejemplo n.º 6
0
def search(i):
    x = (livepopulartimes.get_populartimes_by_PlaceID(GOOGLE_MAPS_API_KEY, "ChIJfz9ctf8W2jERqme0v9wA_og"))
    return (x["populartimes"][i])