From: Stephen Finucane Date: Fri, 24 Jun 2016 16:28:14 +0000 (+0100) Subject: models: Return QuerySet from 'Patch.checks' X-Git-Tag: v2.0.0-rc1~331 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6d4d3220b04f08e075b38f4654601135007d505;p=thirdparty%2Fpatchwork.git models: Return QuerySet from 'Patch.checks' Previously this returned a list. However, a QuerySet is more flexible and is required to provide a generic check endpoint at some point in the future. Signed-off-by: Stephen Finucane Reviewed-by: Andy Doan --- diff --git a/patchwork/models.py b/patchwork/models.py index a8e93edb..e07b1536 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -425,17 +425,22 @@ class Patch(Submission): type. """ unique = {} + duplicates = [] for check in self.check_set.all(): ctx = check.context - # recheck condition - ignore the older result - if ctx in unique and unique[ctx].date > check.date: - continue + if ctx in unique: + # recheck condition - ignore the older result + if unique[ctx].date > check.date: + duplicates.append(check.id) + continue + duplicates.append(unique[ctx].id) unique[ctx] = check - return list(unique.values()) + # filter out the "duplicates" or older, now-invalid results + return self.check_set.all().exclude(id__in=duplicates) @property def check_count(self):