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
1b38000e
Commit
1b38000e
authored
May 09, 2022
by
lyh3024
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'master'
add properties See merge request lyh3024/knowledge_graph!16
parents
aff9d403
d1d28556
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
14 deletions
+26
-14
tests.py
block/tests.py
+12
-2
views.py
block/views.py
+10
-8
views.py
domain/views.py
+3
-3
views.py
route/views.py
+1
-1
No files found.
block/tests.py
View file @
1b38000e
...
...
@@ -52,6 +52,16 @@ def test(i):
r
.
save
()
def
test2
():
time1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
5
)
for
i
in
range
(
10
):
account
=
Account
.
nodes
[
i
:
i
+
1
][
0
]
transaction
=
Transaction
.
nodes
[
i
:
i
+
1
][
0
]
r
=
account
.
transfer_out
.
connect
(
transaction
,
{
"index"
:
"131"
,
"date"
:
time1
})
r
.
save
()
if
__name__
==
'__main__'
:
for
i
in
range
(
1
,
20
):
test
(
i
)
# for i in range(1, 20):
# test(i)
test2
()
block/views.py
View file @
1b38000e
...
...
@@ -16,22 +16,22 @@ def get_account(account, from_time, end_time):
if
from_time
:
param
=
{
"account"
:
account
,
'from_time'
:
from_time
.
timestamp
(),
"end_time"
:
end_time
.
timestamp
()}
query
=
'match(a:Account)-[out:TRANSFER_OUT]->(t:Transaction) '
\
'where a.address
= $account and out.date >= $from_time and out.date <= $end_time return a.address
'
'where a.address
contains $account and out.date >= $from_time and out.date <= $end_time return a.address limit 100
'
items
=
db
.
cypher_query
(
query
,
param
)[
0
]
addresses
=
[
item
[
0
]
for
item
in
items
]
else
:
node
=
Account
.
nodes
.
get_or_none
(
address
=
account
)
if
node
:
addresses
=
[
node
.
address
]
node
s
=
Account
.
nodes
.
filter
(
address__contains
=
account
)
.
all
(
)
if
node
s
:
addresses
=
[
node
.
address
for
node
in
nodes
]
else
:
if
from_time
:
param
=
{
'from_time'
:
from_time
.
timestamp
(),
"end_time"
:
end_time
.
timestamp
()}
query
=
'match(a:Account)-[out:TRANSFER_OUT]->(t:Transaction) '
\
'where out.date >= $from_time and out.date <= $end_time return a.address '
'where out.date >= $from_time and out.date <= $end_time return a.address
limit 100
'
items
=
db
.
cypher_query
(
query
,
param
)[
0
]
addresses
=
[
item
[
0
]
for
item
in
items
]
else
:
nodes
=
Account
.
nodes
.
all
()
nodes
=
Account
.
nodes
[:
100
]
addresses
=
[
node
.
address
for
node
in
nodes
]
return
addresses
...
...
@@ -61,8 +61,10 @@ def get_block_list(request):
param
=
{
'addresses'
:
addresses
}
query
=
'match(a:Account)-[out:TRANSFER_OUT]->(t:Transaction) where a.address in $addresses '
\
'return a.address, sum(t.amount)'
'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
]
deal_amount_dict
=
{}
for
item
in
items
:
...
...
@@ -72,7 +74,7 @@ def get_block_list(request):
# 账户
transactions
=
[]
for
a
in
accounts
:
resp_nodes
.
append
(
gen_node_with_properties_json
(
a
,
{
"dealAmount"
:
deal_amount_dict
.
get
(
a
.
address
)}))
resp_nodes
.
append
(
gen_node_with_properties_json
(
a
,
{
"dealAmount"
:
deal_amount_dict
.
get
(
a
.
address
)
,
"maxAmount"
:
max_amount
,
"minAmount"
:
min_amount
}))
node_ids
.
append
(
a
.
id
)
next_nodes
=
a
.
transfer_out
.
all
()
for
next_node
in
next_nodes
:
...
...
domain/views.py
View file @
1b38000e
...
...
@@ -34,7 +34,7 @@ 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'
'where l.label_name = $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'
...
...
@@ -44,11 +44,11 @@ def get_request_ips(label, from_time, end_time):
if
from_time
:
param
=
{
"from_time"
:
from_time
.
timestamp
(),
"end_time"
:
end_time
.
timestamp
()}
query
=
'match (r:RequestIp)-[req:REQUEST]->(d:DomainName)-[]->(l:Label) '
\
'where req.date >= $from_time and req.date <= $end_time return r.request_ip'
'where req.date >= $from_time and req.date <= $end_time return r.request_ip
limit 100
'
nodes
=
db
.
cypher_query
(
query
,
param
)[
0
]
ips
=
[
node
[
0
]
for
node
in
nodes
]
else
:
nodes
=
RequestIp
.
nodes
.
all
()
nodes
=
RequestIp
.
nodes
[:
100
]
ips
=
[
node
.
request_ip
for
node
in
nodes
]
return
ips
except
Exception
as
e
:
...
...
route/views.py
View file @
1b38000e
...
...
@@ -70,7 +70,7 @@ def get_first_ips(province, city, isp, root_ip, from_time, end_time):
query
+=
query_extend
[
i
]
else
:
query
+=
'and '
+
query_extend
[
i
]
query
+=
'return f.ip'
query
+=
'return f.ip
limit 100
'
items
=
db
.
cypher_query
(
query
,
params
)[
0
]
ips
=
[
item
[
0
]
for
item
in
items
]
...
...
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