676834353b0d

Categorize only the last signoff of each user.

On the index view, all the signoff of a single user (done on precursors of a
cset) were displayed in the counts.

This patch make sure only the last signoff of each user is counted, so that the
final vote on the latest version of a cset gets displayed.
[view raw] [browse files]
author Christophe de Vienne <cdevienne@gmail.com>
date Wed, 29 Oct 2014 14:49:08 +0100
parents 354188b0eca0
children d483f003d230
branches/tags (none)
files review/web.py

Changes

--- a/review/web.py	Wed Oct 29 14:32:27 2014 +0100
+++ b/review/web.py	Wed Oct 29 14:49:08 2014 +0100
@@ -53,10 +53,21 @@
     except (IndexError, KeyError):
         return 'con'
 
+def _last_signoffs(signoffs):
+    last_signoff_by_author = {}
+    for signoff in signoffs:
+        author = signoff.author
+        if (author in last_signoff_by_author and
+                last_signoff_by_author[author].hgdate > signoff.hgdate):
+            continue
+        last_signoff_by_author[author] = signoff
+    return last_signoff_by_author.values()
+
 def _categorize_signoffs(signoffs):
-    return { 'yes': len(filter(lambda s: s.opinion == 'yes', signoffs)),
-             'no': len(filter(lambda s: s.opinion == 'no', signoffs)),
-             'neutral': len(filter(lambda s: s.opinion == '', signoffs)),}
+    last_signoffs = _last_signoffs(signoffs)
+    return { 'yes': len(filter(lambda s: s.opinion == 'yes', last_signoffs)),
+             'no': len(filter(lambda s: s.opinion == 'no', last_signoffs)),
+             'neutral': len(filter(lambda s: s.opinion == '', last_signoffs)),}
 
 def _email(s):
     return fromlocal(email(s))