Change ready_at to first_ready_at and make a unit test for it

This commit is contained in:
Rachid Mrad 2023-12-21 14:48:54 -05:00
parent 1be00962ac
commit 92f17c437f
No known key found for this signature in database
GPG key ID: EF38E4CEC4A8F3CF
3 changed files with 40 additions and 8 deletions

View file

@ -967,7 +967,7 @@ class Domain(TimeStampedModel, DomainHelper):
help_text="Deleted at date",
)
ready_at = DateField(
first_ready_at = DateField(
null=True,
editable=False,
help_text="The last time this domain moved into the READY state",
@ -1336,7 +1336,11 @@ class Domain(TimeStampedModel, DomainHelper):
"""
logger.info("Changing to ready state")
logger.info("able to transition to ready state")
self.ready_at = timezone.now()
# if self.first_ready_at is not None, this means that his
# domain wasr READY, then not READY, then is READY again.
# We do not want to overwrite first_ready_at.
if self.first_ready_at is None:
self.first_ready_at = timezone.now()
@transition(
field="state",