Fix the user directory becoming broken (and noisy errors being logged) when knocking and room statistics are in use. (#10344)
Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
This commit is contained in:
parent
751372fa61
commit
ca9dface8c
|
@ -0,0 +1 @@
|
||||||
|
Fix the user directory becoming broken (and noisy errors being logged) when knocking and room statistics are in use.
|
|
@ -434,7 +434,7 @@ class StatsStore(StateDeltasStore):
|
||||||
]
|
]
|
||||||
|
|
||||||
relative_updates = [
|
relative_updates = [
|
||||||
"%(field)s = EXCLUDED.%(field)s + %(table)s.%(field)s"
|
"%(field)s = EXCLUDED.%(field)s + COALESCE(%(table)s.%(field)s, 0)"
|
||||||
% {"table": table, "field": field}
|
% {"table": table, "field": field}
|
||||||
for field in additive_relatives.keys()
|
for field in additive_relatives.keys()
|
||||||
]
|
]
|
||||||
|
@ -474,6 +474,9 @@ class StatsStore(StateDeltasStore):
|
||||||
self.db_pool.simple_insert_txn(txn, table, merged_dict)
|
self.db_pool.simple_insert_txn(txn, table, merged_dict)
|
||||||
else:
|
else:
|
||||||
for (key, val) in additive_relatives.items():
|
for (key, val) in additive_relatives.items():
|
||||||
|
if current_row[key] is None:
|
||||||
|
current_row[key] = val
|
||||||
|
else:
|
||||||
current_row[key] += val
|
current_row[key] += val
|
||||||
current_row.update(absolutes)
|
current_row.update(absolutes)
|
||||||
self.db_pool.simple_update_one_txn(txn, table, keyvalues, current_row)
|
self.db_pool.simple_update_one_txn(txn, table, keyvalues, current_row)
|
||||||
|
@ -604,6 +607,7 @@ class StatsStore(StateDeltasStore):
|
||||||
"invited_members": membership_counts.get(Membership.INVITE, 0),
|
"invited_members": membership_counts.get(Membership.INVITE, 0),
|
||||||
"left_members": membership_counts.get(Membership.LEAVE, 0),
|
"left_members": membership_counts.get(Membership.LEAVE, 0),
|
||||||
"banned_members": membership_counts.get(Membership.BAN, 0),
|
"banned_members": membership_counts.get(Membership.BAN, 0),
|
||||||
|
"knocked_members": membership_counts.get(Membership.KNOCK, 0),
|
||||||
"local_users_in_room": len(local_users_in_room),
|
"local_users_in_room": len(local_users_in_room),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue