heartwood every commit a ring

Add cached properties to improve performance

7285b1b8 by Isaac Bythewood · 3 years ago

modified properties/models.py
@@ -1,5 +1,5 @@import uuidimport reimport uuidimport requestsfrom django.contrib.auth import get_user_model
@@ -7,6 +7,7 @@ from django.core.mail import EmailMessagefrom django.db import modelsfrom django.template.loader import render_to_stringfrom django.utils import timezonefrom django.utils.functional import cached_propertyUser = get_user_model()
@@ -239,7 +240,7 @@ class Property(AlertsMixin, SecurityMixin, models.Model):    def total_checks(self):        return self.statuses.count()    @property    @cached_property    def current_status(self):        try:            return self.statuses.latest("created_at").status_code
@@ -257,7 +258,7 @@ class Property(AlertsMixin, SecurityMixin, models.Model):        except TypeError:            return 0    @property    @cached_property    def latest_headers(self):        try:            # return all headers lowercase to make them easier to use