Fixes deletion of lists

This commit is contained in:
Mouse Reeve
2022-01-07 13:30:11 -08:00
parent 0580b66c3b
commit 8a8ce0c0d4
2 changed files with 17 additions and 9 deletions

View File

@ -39,10 +39,15 @@ class RedisStore(ABC):
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
if stores and isinstance(obj, int):
obj_id = obj
else:
obj_id = obj.id
stores = self.get_stores_for_object(obj) if stores is None else stores
pipeline = r.pipeline()
for store in stores:
pipeline.zrem(store, -1, obj.id)
pipeline.zrem(store, -1, obj_id)
pipeline.execute()
def bulk_add_objects_to_store(self, objs, store):