Skip to content

Instantly share code, notes, and snippets.

@tomasonjo
Last active June 29, 2022 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomasonjo/40fcaf3c6dc882eae1a6f41361bc1bf6 to your computer and use it in GitHub Desktop.
Save tomasonjo/40fcaf3c6dc882eae1a6f41361bc1bf6 to your computer and use it in GitHub Desktop.
df = gds.run_cypher("""
MATCH (u:User)
CALL {
WITH u
MATCH (u)-[out:P2P]->()
RETURN sum(out.totalAmount) as totalOutgoingAmount, max(out.totalAmount) as maxOutgoingAmount,
avg(out.totalAmount) as avgOutgoingAmount, count(out) as outgoingTransactions
}
CALL {
WITH u
MATCH (u)<-[in:P2P]-()
RETURN sum(in.totalAmount) as totalIncomingAmount, max(in.totalAmount) as maxIncomingAmount,
avg(in.totalAmount) as avgIncomingAmount, count(in) as incomingTransactions
}
RETURN u.guid AS user_id,
u.fraudRisk AS fraudRisk,
size((u)-[:USED]->()) AS numberOfDevices,
size((u)-[:HAS_CC]->()) AS numberOfCCs,
size((u)-[:HAS_IP]->()) AS numberOfIps,
coalesce(totalOutgoingAmount, 0) AS totalOutgoingAmount,
coalesce(avgOutgoingAmount, 0) AS avgOutgoingAmount,
coalesce(maxOutgoingAmount, 0) AS maxOutgoingAmount,
outgoingTransactions,
coalesce(totalIncomingAmount, 0) AS totalIncomingAmount,
coalesce(avgIncomingAmount, 0) AS avgIncomingAmount,
coalesce(maxIncomingAmount, 0) AS maxIncomingAmount,
incomingTransactions
""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment