Commit 378f51c1 by lyh3024

add properties

Change-Id: I9d2f10597937988cc4e16cb21ce75d2eef71b40a
parent bdaa7729
......@@ -84,3 +84,9 @@ def gen_rel_json(r):
"target": e.id,
"label": label
}
def gen_node_with_properties_json(node, properties):
res = gen_node_json(node)
res["properties"] = properties
return res
......@@ -3,7 +3,7 @@
from django.http import JsonResponse
from neomodel import db
from block.models import Account, Block, Contract, Transaction, Miner, gen_node_json, gen_rel_json
from block.models import Account, Block, Contract, Transaction, Miner, gen_node_json, gen_rel_json, gen_node_with_properties_json
from utils import tools
......@@ -59,10 +59,20 @@ def get_block_list(request):
accounts = Account.nodes.filter(address__in=addresses)
param = {'addresses': addresses}
query = 'match(a:Account)-[out:TRANSFER_OUT]->(t:Transaction) where a.address in $addresses ' \
'return a.address, sum(t.amount)'
items = db.cypher_query(query, param)[0]
deal_amount_dict = {}
for item in items:
address, num = item
deal_amount_dict[address] = num
# 账户
transactions = []
for a in accounts:
resp_nodes.append(gen_node_json(a))
resp_nodes.append(gen_node_with_properties_json(a, {"dealNum": deal_amount_dict.get(a.address)}))
node_ids.append(a.id)
next_nodes = a.transfer_out.all()
for next_node in next_nodes:
......
......@@ -69,4 +69,4 @@ def test1(i):
if __name__ == "__main__":
for i in range(1, 20):
test1(i)
test(i)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment