Skip to content

Commit

Permalink
Adjust first voter selection to not include any floating reference vo…
Browse files Browse the repository at this point in the history
…ters,

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.
  • Loading branch information
Kinematics committed Jun 19, 2015
1 parent 3dfbd68 commit de7d96c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions TallyCore/TextResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -239,7 +240,11 @@ private void AddCompactVoteNumber(int votes)
/// <param name="voters">The list of voters.</param>
private void AddCompactVoters(HashSet<string> 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);

Expand Down Expand Up @@ -311,7 +316,11 @@ private void AddTaskLabel(string task)
/// <param name="voters">The set of voters being added.</param>
private void AddVoters(HashSet<string> 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);

Expand Down

0 comments on commit de7d96c

Please sign in to comment.