From 17b3923747880a8b070d1885e98abf3c30d837cf Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 12 Sep 2023 17:49:17 -0600 Subject: [PATCH] Do not need to fetch all archives when checking if domain has archives. --- modules/archive/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/archive/models.py b/modules/archive/models.py index d9e3e860..8e2c17a8 100644 --- a/modules/archive/models.py +++ b/modules/archive/models.py @@ -93,8 +93,10 @@ class Archive(Base, ModelHelper): session.delete(self) if self.domain: - domain_archives = [i.id for i in self.domain.archives] - if not domain_archives: + # Delete a domain if it has no Archives. + try: + next(i.id for i in self.domain.archives) + except StopIteration: self.domain.delete() @property