From 193a940fa0f62ceb4f36fd325a7b7eed2391d43e Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sun, 18 Aug 2013 18:16:12 +0200 Subject: Track and show the last time an email was sent for a patch This tracks all the emails that are sent on a patch. Note that this currently only picks up emalis when the attach thread function is used, since there is no cronjob that fetches this data yet. When that job is added, it should also update this field. --- pgcommitfest/commitfest/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pgcommitfest/commitfest/models.py') diff --git a/pgcommitfest/commitfest/models.py b/pgcommitfest/commitfest/models.py index e7ac9c7..2538e08 100644 --- a/pgcommitfest/commitfest/models.py +++ b/pgcommitfest/commitfest/models.py @@ -77,6 +77,10 @@ class Patch(models.Model): created = models.DateTimeField(blank=False, null=False, auto_now_add=True) modified = models.DateTimeField(blank=False, null=False) + # Materialize the last time an email was sent on any of the threads + # that's attached to this message. + lastmail = models.DateTimeField(blank=True, null=True) + # Some accessors @property def authors_string(self): @@ -101,6 +105,15 @@ class Patch(models.Model): if not self.modified or newmod > self.modified: self.modified = newmod + def update_lastmail(self): + # Update the lastmail field, based on the newest email in any of + # the threads attached to it. + threads = list(self.mailthread_set.all()) + if len(threads) == 0: + self.lastmail = None + else: + self.lastmail = max(threads, key=lambda t:t.latestmessage).latestmessage + def __unicode__(self): return self.name -- cgit v1.2.3