Python formatting
This commit is contained in:
parent
bd8858830a
commit
0bbaf0a562
|
@ -104,7 +104,7 @@ class ActivityStream(RedisStore):
|
|||
)
|
||||
|
||||
def get_objects_for_store(self, store):
|
||||
user = models.User.objects.get(id=store.split('-')[0])
|
||||
user = models.User.objects.get(id=store.split("-")[0])
|
||||
return self.get_statuses_for_user(user)
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ r = redis.Redis(
|
|||
|
||||
class RedisStore(ABC):
|
||||
""" sets of ranked, related objects, like statuses for a user's feed """
|
||||
|
||||
max_length = settings.MAX_STREAM_LENGTH
|
||||
|
||||
def get_value(self, obj):
|
||||
|
@ -26,9 +27,7 @@ class RedisStore(ABC):
|
|||
# add the status to the feed
|
||||
pipeline.zadd(store, value)
|
||||
# trim the store
|
||||
pipeline.zremrangebyrank(
|
||||
store, 0, -1 * self.max_length
|
||||
)
|
||||
pipeline.zremrangebyrank(store, 0, -1 * self.max_length)
|
||||
if not execute:
|
||||
return pipeline
|
||||
# and go!
|
||||
|
@ -47,9 +46,7 @@ class RedisStore(ABC):
|
|||
for obj in objs[: self.max_length]:
|
||||
pipeline.zadd(store, self.get_value(obj))
|
||||
if objs:
|
||||
pipeline.zremrangebyrank(
|
||||
store, 0, -1 * self.max_length
|
||||
)
|
||||
pipeline.zremrangebyrank(store, 0, -1 * self.max_length)
|
||||
pipeline.execute()
|
||||
|
||||
def bulk_remove_objects_from_store(self, objs, store):
|
||||
|
@ -73,9 +70,7 @@ class RedisStore(ABC):
|
|||
|
||||
# only trim the store if objects were added
|
||||
if queryset.exists():
|
||||
pipeline.zremrangebyrank(
|
||||
store, 0, -1 * self.max_length
|
||||
)
|
||||
pipeline.zremrangebyrank(store, 0, -1 * self.max_length)
|
||||
pipeline.execute()
|
||||
|
||||
@abstractmethod
|
||||
|
|
Loading…
Reference in New Issue