Last active
May 22, 2017 21:22
-
-
Save andyrobbins/d861a0b6a7672cb7ab9525f89be5b885 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from neo4j.v1 import GraphDatabase, basic_auth | |
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4jj")) | |
session = driver.session() | |
for result in session.run(""" | |
MATCH (u:User) | |
RETURN COUNT(u) | |
"""): | |
TotalUserCount = int(result._values[0]) | |
for result in session.run(""" | |
MATCH (c:Computer)-[r:HasSession]->(u:User) | |
RETURN COUNT(DISTINCT(u)) | |
"""): | |
UniqueUsersWithSessions = int(result._values[0]) | |
# Thanks Tom Porter (@porterhau5) for correction | |
SessionPercentage = int((float(TotalUserCount) / float(UniqueUsersWithSessions)) * 100) | |
print str(SessionPercentage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment