# HG changeset patch # User Christophe de Vienne # Date 1414590548 -3600 # Node ID 676834353b0dcbb5c4eeddada4ea73d6b157a573 # Parent 354188b0eca027b5845fe6ca82af22d81f68f656 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. diff -r 354188b0eca0 -r 676834353b0d review/web.py --- 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))