コード例 #1
0
def fetchPlacesbyCategoriesDuration(categories, duration):
    catArr = categories.lower().split(",")
    inQry = {"category": {"$in": catArr}}

    dbConn = MongoConnection()
    places_coll = dbConn.getPlacesCollection()

    places = places_coll.find(inQry)

    locations = []
    validLocations = []
    currDuration = 0
    #print(places.count())
    if (places):
        for aPlace in places:
            locations.append(aPlace)

        shuffleList(locations)
        for aLoc in locations:
            print(aLoc['name'], aLoc['duration'])
            if ((currDuration + aLoc['duration']) < duration):
                currDuration += aLoc['duration']
                validLocations.append(aLoc)
            else:
                break

        print(currDuration)

        print([aPlace['name'] for aPlace in validLocations])
コード例 #2
0
def fetchPlacesByCategories(categories):

    inQry = {"category": {"$in": categories}}

    dbConn = MongoConnection()
    places_coll = dbConn.getPlacesCollection()

    places = places_coll.find(inQry)

    locations = []

    if (places):
        for aPlace in places:
            locations.append(aPlace)
    return shuffleList(locations)
コード例 #3
0
def fetchPlacesByCategoriesBudget(categories, budget):
    current_app.logger.info(categories)
    current_app.logger.info(budget)
    query = dict()
    query["category"] = {"$in": categories}
    query["Price"] = {"$lte": budget}
    #print(query)
    dbConn = MongoConnection()
    places_coll = dbConn.getPlacesCollection()
    current_app.logger.info(query)
    places = places_coll.find(query, {
        "_id": 0,
        "suitableAge": 0,
        "location": 0,
        "wayToGetThere": 0
    })

    locations = []

    if (places):
        for aPlace in places:
            locations.append(aPlace)
    return shuffleList(locations)