Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4cbcd4a

Browse files
authored
Misc clean-up of push rules datastore (#12856)
1 parent 6aeee9a commit 4cbcd4a

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

changelog.d/12856.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clean-up the push rules datastore.

synapse/storage/databases/main/push_rule.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async def get_push_rules_for_user(self, user_id: str) -> List[JsonDict]:
174174
"conditions",
175175
"actions",
176176
),
177-
desc="get_push_rules_enabled_for_user",
177+
desc="get_push_rules_for_user",
178178
)
179179

180180
rows.sort(key=lambda row: (-int(row["priority_class"]), -int(row["priority"])))
@@ -188,10 +188,10 @@ async def get_push_rules_enabled_for_user(self, user_id: str) -> Dict[str, bool]
188188
results = await self.db_pool.simple_select_list(
189189
table="push_rules_enable",
190190
keyvalues={"user_name": user_id},
191-
retcols=("user_name", "rule_id", "enabled"),
191+
retcols=("rule_id", "enabled"),
192192
desc="get_push_rules_enabled_for_user",
193193
)
194-
return {r["rule_id"]: False if r["enabled"] == 0 else True for r in results}
194+
return {r["rule_id"]: bool(r["enabled"]) for r in results}
195195

196196
async def have_push_rules_changed_for_user(
197197
self, user_id: str, last_id: int
@@ -213,11 +213,7 @@ def have_push_rules_changed_txn(txn: LoggingTransaction) -> bool:
213213
"have_push_rules_changed", have_push_rules_changed_txn
214214
)
215215

216-
@cachedList(
217-
cached_method_name="get_push_rules_for_user",
218-
list_name="user_ids",
219-
num_args=1,
220-
)
216+
@cachedList(cached_method_name="get_push_rules_for_user", list_name="user_ids")
221217
async def bulk_get_push_rules(
222218
self, user_ids: Collection[str]
223219
) -> Dict[str, List[JsonDict]]:
@@ -249,9 +245,7 @@ async def bulk_get_push_rules(
249245
return results
250246

251247
@cachedList(
252-
cached_method_name="get_push_rules_enabled_for_user",
253-
list_name="user_ids",
254-
num_args=1,
248+
cached_method_name="get_push_rules_enabled_for_user", list_name="user_ids"
255249
)
256250
async def bulk_get_push_rules_enabled(
257251
self, user_ids: Collection[str]

0 commit comments

Comments
 (0)