Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
knowledge_graph
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sun Long
knowledge_graph
Commits
378f51c1
Commit
378f51c1
authored
May 09, 2022
by
lyh3024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add properties
Change-Id: I9d2f10597937988cc4e16cb21ce75d2eef71b40a
parent
bdaa7729
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
models.py
block/models.py
+6
-0
views.py
block/views.py
+12
-2
tests.py
route/tests.py
+1
-1
No files found.
block/models.py
View file @
378f51c1
...
...
@@ -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
block/views.py
View file @
378f51c1
...
...
@@ -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
:
...
...
route/tests.py
View file @
378f51c1
...
...
@@ -69,4 +69,4 @@ def test1(i):
if
__name__
==
"__main__"
:
for
i
in
range
(
1
,
20
):
test
1
(
i
)
test
(
i
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment