From de7d96c50f8488c889ab444588b33abd48ce9bf4 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 18 Jun 2015 20:32:26 -0500 Subject: [PATCH] Adjust first voter selection to not include any floating reference voters, since they can end up before the final version of the proposal they voted for. Fall back on the default method if the above filter leaves us with no voters. --- TallyCore/TextResults.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/TallyCore/TextResults.cs b/TallyCore/TextResults.cs index 99e997ce..7bf71ab9 100644 --- a/TallyCore/TextResults.cs +++ b/TallyCore/TextResults.cs @@ -113,6 +113,7 @@ private void ConstructNormalOutput() AddTaskLabel(taskGroup.Key); + // Show each vote result in descending number of votes. foreach (var vote in taskGroup.OrderByDescending(v => v.Value.Count(vc => VoteCounter.PlanNames.Contains(vc) == false))) { if (DisplayMode == DisplayMode.Compact) @@ -239,7 +240,11 @@ private void AddCompactVoteNumber(int votes) /// The list of voters. private void AddCompactVoters(HashSet voters) { - string firstVoter = voters.OrderBy(v => VoteCounter.VoterMessageId[v]).First(); + string firstVoter = voters.Except(VoteCounter.LastFloatingReferencePerAuthor.Select(p => p.Author)) + .OrderBy(v => VoteCounter.VoterMessageId[v]).FirstOrDefault(); + + if (firstVoter == null) + firstVoter = voters.OrderBy(v => VoteCounter.VoterMessageId[v]).First(); var remainder = voters.Where(v => v != firstVoter && VoteCounter.PlanNames.Contains(v) == false).OrderBy(v => v); @@ -311,7 +316,11 @@ private void AddTaskLabel(string task) /// The set of voters being added. private void AddVoters(HashSet voters) { - string firstVoter = voters.OrderBy(v => VoteCounter.VoterMessageId[v]).First(); + string firstVoter = voters.Except(VoteCounter.LastFloatingReferencePerAuthor.Select(p => p.Author)) + .OrderBy(v => VoteCounter.VoterMessageId[v]).FirstOrDefault(); + + if (firstVoter == null) + firstVoter = voters.OrderBy(v => VoteCounter.VoterMessageId[v]).First(); AddVoter(firstVoter);