Beispiel #1
0
def list(request):
    db = DynamoDb()
    print "Calling list heatmaps.  This should list out the existing heatmaps"
    result = db.get_key("heatmaps")
    heatmaps = []
    if result and len(result['Items']) > 0:
        heatmaps = result['Items']
    return heatmaps
Beispiel #2
0
def get(request, id):
    db = DynamoDb()
    result = db.get_key("heatmaps")
    if result and len(result['Items']) > 0:
        for item in result['Items']:
            for heatmap in item['value']:
                if heatmap['id'] == id:
                    return heatmap
    return None
Beispiel #3
0
def post(request, meta):
    db = DynamoDb()

    heatmapArr = []
    existingHeatmaps = db.get_key("heatmaps")
    heatmapArr = existingHeatmaps['Items'][0]['value']

    # TODO: Remove [0] if testing fails
    heatmapArr.append({"id": meta['id'], "heatmap": meta})
    return db.set("heatmaps", heatmapArr)
Beispiel #4
0
def delete(request, id):
    db = DynamoDb()

    existingHeatmaps = db.get_key("heatmaps")
    heatmapArr = existingHeatmaps['Items'][0]['value']
    print heatmapArr

    for heatmap in heatmapArr:
        if heatmap['id'] == id:
            heatmapArr.remove(heatmap)
    print heatmapArr
    return db.set("heatmaps", heatmapArr)
Beispiel #5
0
def put(request, id, meta):
    db = DynamoDb()

    existingHeatmaps = db.get_key("heatmaps")
    heatmapArr = existingHeatmaps['Items'][0]['value']

    newHeatmap = {"id": meta['id'], "heatmap": meta}
    heatmapArr = [
        newHeatmap if heatmap['id'] == id else heatmap
        for heatmap in heatmapArr
    ]
    return db.set("heatmaps", heatmapArr)
Beispiel #6
0
def get(request, facetid):
    db = DynamoDb()
    result = db.get_key(facetid)
    result = json.dumps(result, cls=util.DynamoDbDecoder)
    return result