summary refs log tree commit diff
path: root/contrib
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-01-22 13:35:34 +0000
committerErik Johnston <erik@matrix.org>2015-01-22 13:35:34 +0000
commit7f058c5ff743e2cf563b9aa5436ee9801a14e633 (patch)
tree8ef0270ede93c304b0859c4e8fba49b9581b2514 /contrib
parentAdd twisted Service interface (diff)
parentMove experiments, graph and cmdclient into contrib (diff)
downloadsynapse-7f058c5ff743e2cf563b9aa5436ee9801a14e633.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj-perf
Conflicts:
	synapse/app/homeserver.py
Diffstat (limited to '')
-rwxr-xr-xcontrib/cmdclient/console.py (renamed from cmdclient/console.py)0
-rw-r--r--contrib/cmdclient/http.py (renamed from cmdclient/http.py)0
-rw-r--r--contrib/experiments/cursesio.py (renamed from experiments/cursesio.py)0
-rw-r--r--contrib/experiments/test_messaging.py (renamed from experiments/test_messaging.py)0
-rw-r--r--contrib/graph/graph.py (renamed from graph/graph.py)0
-rw-r--r--contrib/graph/graph2.py (renamed from graph/graph2.py)30
6 files changed, 24 insertions, 6 deletions
diff --git a/cmdclient/console.py b/contrib/cmdclient/console.py
index d9c6ec6a70..d9c6ec6a70 100755
--- a/cmdclient/console.py
+++ b/contrib/cmdclient/console.py
diff --git a/cmdclient/http.py b/contrib/cmdclient/http.py
index 869f782ec1..869f782ec1 100644
--- a/cmdclient/http.py
+++ b/contrib/cmdclient/http.py
diff --git a/experiments/cursesio.py b/contrib/experiments/cursesio.py
index 95d87a1fda..95d87a1fda 100644
--- a/experiments/cursesio.py
+++ b/contrib/experiments/cursesio.py
diff --git a/experiments/test_messaging.py b/contrib/experiments/test_messaging.py
index fedf786cec..fedf786cec 100644
--- a/experiments/test_messaging.py
+++ b/contrib/experiments/test_messaging.py
diff --git a/graph/graph.py b/contrib/graph/graph.py
index b2acadcf5e..b2acadcf5e 100644
--- a/graph/graph.py
+++ b/contrib/graph/graph.py
diff --git a/graph/graph2.py b/contrib/graph/graph2.py
index b9b8a562a0..6b551d42e5 100644
--- a/graph/graph2.py
+++ b/contrib/graph/graph2.py
@@ -23,14 +23,27 @@ import argparse
 from synapse.events import FrozenEvent
 
 
-def make_graph(db_name, room_id, file_prefix):
+def make_graph(db_name, room_id, file_prefix, limit):
     conn = sqlite3.connect(db_name)
 
-    c = conn.execute(
-        "SELECT json FROM event_json where room_id = ?",
-        (room_id,)
+    sql = (
+        "SELECT json FROM event_json as j "
+        "INNER JOIN events as e ON e.event_id = j.event_id "
+        "WHERE j.room_id = ?"
     )
 
+    args = [room_id]
+
+    if limit:
+        sql += (
+            " ORDER BY topological_ordering DESC, stream_ordering DESC "
+            "LIMIT ?"
+        )
+
+        args.append(limit)
+
+    c = conn.execute(sql, args)
+
     events = [FrozenEvent(json.loads(e[0])) for e in c.fetchall()]
 
     events.sort(key=lambda e: e.depth)
@@ -128,11 +141,16 @@ if __name__ == "__main__":
     )
     parser.add_argument(
         "-p", "--prefix", dest="prefix",
-        help="String to prefix output files with"
+        help="String to prefix output files with",
+        default="graph_output"
+    )
+    parser.add_argument(
+        "-l", "--limit",
+        help="Only retrieve the last N events.",
     )
     parser.add_argument('db')
     parser.add_argument('room')
 
     args = parser.parse_args()
 
-    make_graph(args.db, args.room, args.prefix)
+    make_graph(args.db, args.room, args.prefix, args.limit)