Misc clean-up of push rules datastore (#12856)

This commit is contained in:
Patrick Cloke 2022-05-25 07:49:12 -04:00 committed by GitHub
parent 6aeee9a19d
commit 4cbcd4a999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

1
changelog.d/12856.misc Normal file
View File

@ -0,0 +1 @@
Clean-up the push rules datastore.

View File

@ -174,7 +174,7 @@ class PushRulesWorkerStore(
"conditions", "conditions",
"actions", "actions",
), ),
desc="get_push_rules_enabled_for_user", desc="get_push_rules_for_user",
) )
rows.sort(key=lambda row: (-int(row["priority_class"]), -int(row["priority"]))) rows.sort(key=lambda row: (-int(row["priority_class"]), -int(row["priority"])))
@ -188,10 +188,10 @@ class PushRulesWorkerStore(
results = await self.db_pool.simple_select_list( results = await self.db_pool.simple_select_list(
table="push_rules_enable", table="push_rules_enable",
keyvalues={"user_name": user_id}, keyvalues={"user_name": user_id},
retcols=("user_name", "rule_id", "enabled"), retcols=("rule_id", "enabled"),
desc="get_push_rules_enabled_for_user", desc="get_push_rules_enabled_for_user",
) )
return {r["rule_id"]: False if r["enabled"] == 0 else True for r in results} return {r["rule_id"]: bool(r["enabled"]) for r in results}
async def have_push_rules_changed_for_user( async def have_push_rules_changed_for_user(
self, user_id: str, last_id: int self, user_id: str, last_id: int
@ -213,11 +213,7 @@ class PushRulesWorkerStore(
"have_push_rules_changed", have_push_rules_changed_txn "have_push_rules_changed", have_push_rules_changed_txn
) )
@cachedList( @cachedList(cached_method_name="get_push_rules_for_user", list_name="user_ids")
cached_method_name="get_push_rules_for_user",
list_name="user_ids",
num_args=1,
)
async def bulk_get_push_rules( async def bulk_get_push_rules(
self, user_ids: Collection[str] self, user_ids: Collection[str]
) -> Dict[str, List[JsonDict]]: ) -> Dict[str, List[JsonDict]]:
@ -249,9 +245,7 @@ class PushRulesWorkerStore(
return results return results
@cachedList( @cachedList(
cached_method_name="get_push_rules_enabled_for_user", cached_method_name="get_push_rules_enabled_for_user", list_name="user_ids"
list_name="user_ids",
num_args=1,
) )
async def bulk_get_push_rules_enabled( async def bulk_get_push_rules_enabled(
self, user_ids: Collection[str] self, user_ids: Collection[str]