[PATCH 08/10] models: Cache 'list_archive_url' property
Stephen Finucane
stephen at that.guru
Sat Oct 1 02:19:19 AEST 2022
We really need to get rid of this from the embedded view. It's way too
slow. For now, we just cache it and leave a note for future us.
Signed-off-by: Stephen Finucane <stephen at that.guru>
---
patchwork/api/embedded.py | 12 ++++++++++++
patchwork/models.py | 6 +++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git patchwork/api/embedded.py patchwork/api/embedded.py
index 7105da08..4cfdf8e6 100644
--- patchwork/api/embedded.py
+++ patchwork/api/embedded.py
@@ -113,6 +113,8 @@ class CoverSerializer(SerializedRelatedField):
'url',
'web_url',
'msgid',
+ # TODO(stephenfin): Drop this in a future API version - it is
+ # too slow to calculate and not necessary here.
'list_archive_url',
'date',
'name',
@@ -149,6 +151,8 @@ class CoverCommentSerializer(SerializedRelatedField):
'url',
'web_url',
'msgid',
+ # TODO(stephenfin): Drop this in a future API version - it is
+ # too slow to calculate and not necessary here.
'list_archive_url',
'date',
)
@@ -174,6 +178,8 @@ class PatchSerializer(SerializedRelatedField):
'url',
'web_url',
'msgid',
+ # TODO(stephenfin): Drop this in a future API version - it is
+ # too slow to calculate and not necessary here.
'list_archive_url',
'date',
'name',
@@ -207,6 +213,8 @@ class PatchCommentSerializer(SerializedRelatedField):
'url',
'web_url',
'msgid',
+ # TODO(stephenfin): Drop this in a future API version - it is
+ # too slow to calculate and not necessary here.
'list_archive_url',
'date',
)
@@ -253,8 +261,12 @@ class ProjectSerializer(SerializedRelatedField):
'web_url',
'scm_url',
'webscm_url',
+ # TODO(stephenfin): Drop this in a future API version - it is
+ # too slow to calculate and not necessary here.
'list_archive_url',
+ # TODO(stephenfin): Ditto
'list_archive_url_format',
+ # TODO(stephenfin): Ditto
'commit_url_format',
)
read_only_fields = fields
diff --git patchwork/models.py patchwork/models.py
index 264af532..d2507d4f 100644
--- patchwork/models.py
+++ patchwork/models.py
@@ -406,7 +406,7 @@ class SubmissionMixin(FilenameMixin, EmailMixin, models.Model):
name = models.CharField(max_length=255)
- @property
+ @cached_property
def list_archive_url(self):
if not self.project.list_archive_url_format:
return None
@@ -719,7 +719,7 @@ class CoverComment(EmailMixin, models.Model):
)
addressed = models.BooleanField(null=True)
- @property
+ @cached_property
def list_archive_url(self):
if not self.cover.project.list_archive_url_format:
return None
@@ -770,7 +770,7 @@ class PatchComment(EmailMixin, models.Model):
)
addressed = models.BooleanField(null=True)
- @property
+ @cached_property
def list_archive_url(self):
if not self.patch.project.list_archive_url_format:
return None
--
2.37.3
More information about the Patchwork
mailing list