diff options
author | Olivier Wilkinson (reivilibre) <olivier@librepush.net> | 2019-08-30 15:13:44 +0100 |
---|---|---|
committer | Olivier Wilkinson (reivilibre) <olivier@librepush.net> | 2019-08-30 15:13:44 +0100 |
commit | 425d44521dd7551c331a773b7d274b71f1c79bf4 (patch) | |
tree | 671c8d346da3f6dea5a9a43670b896847f25b87d /synapse | |
parent | Merge branch 'rei/rss_inc7' into rei/rss_inc8 (diff) | |
parent | `users` table's ID field is actually called `name`. (diff) | |
download | synapse-425d44521dd7551c331a773b7d274b71f1c79bf4.tar.xz |
Merge branch 'rei/rss_inc7' into rei/rss_inc8
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/storage/stats.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/storage/stats.py b/synapse/storage/stats.py index 2bf7b92fa9..f5b7618468 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)), |