From 93bd66ad3ea944283c6ae2f89ced056b4602e2b7 Mon Sep 17 00:00:00 2001 From: Wesley Aptekar-Cassels Date: Wed, 5 Apr 2023 20:37:17 -0400 Subject: [PATCH] Refactor to delete add_object_to_related_stores This is working towards some optimizations. --- bookwyrm/activitystreams.py | 4 +++- bookwyrm/lists_stream.py | 3 +-- bookwyrm/redis_store.py | 4 ---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 74471883e..76872609d 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -39,7 +39,9 @@ class ActivityStream(RedisStore): def add_status(self, status, increment_unread=False): """add a status to users' feeds""" # the pipeline contains all the add-to-stream activities - pipeline = self.add_object_to_related_stores(status, execute=False) + pipeline = self.add_object_to_stores( + status, self.get_stores_for_object(status), execute=False + ) if increment_unread: for user_id in self.get_audience(status): diff --git a/bookwyrm/lists_stream.py b/bookwyrm/lists_stream.py index 7426488ce..20f045afd 100644 --- a/bookwyrm/lists_stream.py +++ b/bookwyrm/lists_stream.py @@ -24,8 +24,7 @@ class ListsStream(RedisStore): def add_list(self, book_list): """add a list to users' feeds""" - # the pipeline contains all the add-to-stream activities - self.add_object_to_related_stores(book_list) + self.add_object_to_stores(book_list, self.get_stores_for_object(book_list)) def add_user_lists(self, viewer, user): """add a user's lists to another user's feed""" diff --git a/bookwyrm/redis_store.py b/bookwyrm/redis_store.py index cd75fc5de..3e88c09ac 100644 --- a/bookwyrm/redis_store.py +++ b/bookwyrm/redis_store.py @@ -32,10 +32,6 @@ class RedisStore(ABC): # and go! return pipeline.execute() - def add_object_to_related_stores(self, obj, execute=True): - """add an object to all suitable stores""" - return self.add_object_to_stores(obj, self.get_stores_for_object(obj), execute) - def remove_object_from_related_stores(self, obj, stores=None): """remove an object from all stores""" # if the stoers are provided, the object can just be an id