def handler()

in functions/APIs/getRecommendations.py [0:0]


def handler(event, context):
    
    graph = Graph()
    
    g = graph.traversal().withRemote(DriverRemoteConnection(myNeptuneEndpoint,"g"))
    
    toReturn = g.V().hasLabel("book").where(inE("purchased").count().is_(P.gt(0))).project("bookId","purchases","friendsPurchased") \
        .by(id()).by(inE("purchased").count()).by(in_().id().fold()).order().by(select("purchases"),Order.decr).limit(5).toList()
    
    response = {
        "statusCode": 200,
        "headers": {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Credentials": True
        },
        "body": json.dumps(toReturn)
    }
    
    print(response)
    return response