1
0
Fork 0

Generate fewer add_status_tasks

Previously, every time a status was saved, a task would start to add it
to people's timelines. This meant there were a ton of duplicate tasks
that were potentially heavy to run. Now, the Status model has a "ready"
field which indicates that it's worth updating the timelines. It
defaults to True, which prevents statuses from accidentally not being
added due to ready state.

The ready state is explicitly set to false in the view, which is the
source of most of the noise for that task.
This commit is contained in:
Mouse Reeve 2022-11-15 14:12:00 -08:00
parent f0b73c18c1
commit 317cf5fcf5
7 changed files with 148 additions and 8 deletions

View file

@ -63,6 +63,9 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
activitypub_field="inReplyTo",
)
thread_id = models.IntegerField(blank=True, null=True)
# statuses get saved a few times, this indicates if they're set
ready = models.BooleanField(default=True)
objects = InheritanceManager()
activity_serializer = activitypub.Note
@ -83,8 +86,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
if not self.reply_parent:
self.thread_id = self.id
super().save(broadcast=False, update_fields=["thread_id"])
super().save(broadcast=False, update_fields=["thread_id"])
def delete(self, *args, **kwargs): # pylint: disable=unused-argument
""" "delete" a status"""
@ -399,7 +401,7 @@ class ReviewRating(Review):
def save(self, *args, **kwargs):
if not self.rating:
raise ValueError("ReviewRating object must include a numerical rating")
return super().save(*args, **kwargs)
super().save(*args, **kwargs)
@property
def pure_content(self):