Fixes boosts removing statuses from feeds

This commit is contained in:
Mouse Reeve 2021-08-23 07:04:59 -07:00
parent e76163ffae
commit f284eebece
2 changed files with 5 additions and 3 deletions

View file

@ -273,9 +273,10 @@ def add_status_on_create(sender, instance, created, *args, **kwargs):
created_date__lt=instance.created_date, created_date__lt=instance.created_date,
) )
for stream in streams.values(): for stream in streams.values():
stream.remove_object_from_related_stores(boosted) audience = streams.get_stores_for_object(instance)
stream.remove_object_from_related_stores(boosted, stores=audience)
for status in old_versions: for status in old_versions:
stream.remove_object_from_related_stores(status) stream.remove_object_from_related_stores(status, stores=audience)
@receiver(signals.post_delete, sender=models.Boost) @receiver(signals.post_delete, sender=models.Boost)

View file

@ -33,8 +33,9 @@ class RedisStore(ABC):
# and go! # and go!
return pipeline.execute() return pipeline.execute()
def remove_object_from_related_stores(self, obj): def remove_object_from_related_stores(self, obj, stores=None):
"""remove an object from all stores""" """remove an object from all stores"""
stores = stores or self.get_stores_for_object(obj)
pipeline = r.pipeline() pipeline = r.pipeline()
for store in self.get_stores_for_object(obj): for store in self.get_stores_for_object(obj):
pipeline.zrem(store, -1, obj.id) pipeline.zrem(store, -1, obj.id)