summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <olivier@librepush.net>2019-08-30 15:13:41 +0100
committerOlivier Wilkinson (reivilibre) <olivier@librepush.net>2019-08-30 15:13:41 +0100
commitb379a11dc22a003494f30820c2c1d6f98f801fda (patch)
tree98050f748090081978bc2339e7198101c798335a
parentFix that became apparent after unit testing (diff)
downloadsynapse-b379a11dc22a003494f30820c2c1d6f98f801fda.tar.xz
`users` table's ID field is actually called `name`.
Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
-rw-r--r--synapse/storage/stats.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/storage/stats.py b/synapse/storage/stats.py
index adb66a1340..5591079cae 100644
--- a/synapse/storage/stats.py
+++ b/synapse/storage/stats.py
@@ -52,8 +52,8 @@ PER_SLICE_FIELDS = {"room": (), "user": ()}
 
 TYPE_TO_TABLE = {"room": ("room_stats", "room_id"), "user": ("user_stats", "user_id")}
 
-# these are the tables which contain our actual subjects
-TYPE_TO_ORIGIN_TABLE = {"room": "rooms", "user": "users"}
+# these are the tables (& ID columns) which contain our actual subjects
+TYPE_TO_ORIGIN_TABLE = {"room": ("rooms", "room_id"), "user": ("users", "name")}
 
 
 class StatsStore(StateDeltasStore):
@@ -173,18 +173,18 @@ class StatsStore(StateDeltasStore):
                 sql = """
                         INSERT OR IGNORE INTO %(table)s_current
                         (%(id_col)s, completed_delta_stream_id, %(zero_cols)s)
-                        SELECT %(id_col)s, NULL, %(zeroes)s FROM %(origin_table)s
+                        SELECT %(origin_id_col)s, NULL, %(zeroes)s FROM %(origin_table)s
                     """
             else:
                 sql = """
                         INSERT INTO %(table)s_current
                         (%(id_col)s, completed_delta_stream_id, %(zero_cols)s)
-                        SELECT %(id_col)s, NULL, %(zeroes)s FROM %(origin_table)s
+                        SELECT %(origin_id_col)s, NULL, %(zeroes)s FROM %(origin_table)s
                         ON CONFLICT DO NOTHING
                     """
 
             table, id_col = TYPE_TO_TABLE[stats_type]
-            origin_table = TYPE_TO_ORIGIN_TABLE[stats_type]
+            origin_table, origin_id_col = TYPE_TO_ORIGIN_TABLE[stats_type]
             zero_cols = list(
                 chain(ABSOLUTE_STATS_FIELDS[stats_type], PER_SLICE_FIELDS[stats_type])
             )
@@ -194,6 +194,7 @@ class StatsStore(StateDeltasStore):
                 % {
                     "table": table,
                     "id_col": id_col,
+                    "origin_id_col": origin_id_col,
                     "origin_table": origin_table,
                     "zero_cols": ", ".join(zero_cols),
                     "zeroes": ", ".join(["0"] * len(zero_cols)),