예제 #1
0
def getPoliticians(request, graph):
    limit = int(request.args.get('limit', 50))
    politicians = list(Politician.match(graph).limit(limit))
    print(politicians)
    politiciansSerialize = list(
        map(lambda politician: politician.serialize(), politicians))
    return jsonify(politiciansSerialize)
예제 #2
0
def updatePolitician(request, graph):
    politician_id = request.form.get('id')
    politician = Politician.match(graph).where(
        f"ID(_) = {politician_id}").first()
    if (not (politician)):
        return jsonify({'error': 'Politician not found'})
    political_party_name = request.form.get('political_party')
    politician.belongs.clear()
    political_party = PoliticalParty(political_party_name)
    politician.belongs.add(political_party)
    graph.push(politician)
    return jsonify(politician.serialize())