Commit 026ff620 by lyh3024

add label

Change-Id: I6daef03347ca86e13800cb41d3b7ca40c1c98914
parent 7a489ae9
......@@ -86,7 +86,8 @@ def gen_rel_json(r):
}
def gen_node_with_properties_json(node, properties):
def gen_node_with_properties_json(node, properties, max_id):
res = gen_node_json(node)
res["max_id"] = max_id
res["properties"] = properties
return res
......@@ -42,6 +42,7 @@ def get_block_list(request):
account = request.GET.get("account")
from_time = request.GET.get('from_time')
end_time = request.GET.get('end_time')
sort_type = request.GET.get('sort_type')
if from_time and not end_time:
resp = tools.dec_error_resp("end_time is null")
......@@ -60,21 +61,35 @@ 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) order by sum(t.amount) desc'
if sort_type and int(sort_type) != 2:
query = 'match(a:Account)-[out:TRANSFER_OUT]->(t:Transaction) where a.address in $addresses ' \
'return a.address, count(out) order by count(out) desc'
else:
query = 'match(a:Account)-[out:TRANSFER_OUT]->(t:Transaction) where a.address in $addresses ' \
'return a.address, sum(t.amount) order by sum(t.amount) desc'
items = db.cypher_query(query, param)[0]
max_amount = items[0][1]
min_amount = items[len(items)-1][1]
max_address = items[0][0]
max_num = items[0][1]
min_num = items[len(items)-1][1]
deal_amount_dict = {}
deal_dict = {}
for item in items:
address, num = item
deal_amount_dict[address] = num
deal_dict[address] = num
max_id = 0
for a in accounts:
if a.address == max_address:
max_id = a.id
break
# 账户
transactions = []
for a in accounts:
resp_nodes.append(gen_node_with_properties_json(a, {"dealAmount": deal_amount_dict.get(a.address), "maxAmount": max_amount, "minAmount": min_amount}))
if sort_type and int(sort_type) != 2:
resp_nodes.append(gen_node_with_properties_json(a, {"dealNum": deal_dict.get(a.address), "maxNum": max_num, "minNum": min_num}, max_id))
else:
resp_nodes.append(gen_node_with_properties_json(a, {"dealAmount": deal_dict.get(a.address), "maxAmount": max_num, "minAmount": min_num}, max_id))
node_ids.append(a.id)
next_nodes = a.transfer_out.all()
for next_node in next_nodes:
......
......@@ -34,10 +34,10 @@ def get_request_ips(label, from_time, end_time):
if from_time:
param = {"label": label, "from_time": from_time.timestamp(), "end_time": end_time.timestamp()}
query = 'match (r:RequestIp)-[req:REQUEST]->(d:DomainName)-[]->(l:Label) ' \
'where l.label_name = $label and req.date >= $from_time and req.date <= $end_time return r.request_ip limit 100'
'where l.label_name contains $label and req.date >= $from_time and req.date <= $end_time return r.request_ip limit 100'
else:
param = {"label": label}
query = 'match (r:RequestIp)-[]->(d:DomainName)-[]->(l:Label) where l.label_name = $label return r.request_ip'
query = 'match (r:RequestIp)-[]->(d:DomainName)-[]->(l:Label) where l.label_name contains $label return r.request_ip'
nodes = db.cypher_query(query, param)[0]
ips = [node[0] for node in nodes]
else:
......
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