Skip to content

Commit

Permalink
If the ranking algorithm returns an empty result instead of null, cat…
Browse files Browse the repository at this point in the history
…ch that

rather than letting it potentially break the output.
  • Loading branch information
Kinematics committed Jun 15, 2017
1 parent e0ea42c commit 99f6149
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions NetTally.Core/Output/TallyOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ private void AddCompactTask(KeyValuePair<string, RankResults> task)
int num = 1;
foreach (var entry in task.Value)
{
if (entry.Option == null)
continue;

string debug = AdvancedOptions.Instance.DebugMode ? $" >>> {entry.Debug}" : string.Empty;
sb.AppendLine($"[{num++}] {entry.Option}{debug}");
}
Expand All @@ -233,6 +236,9 @@ private void AddCompleteTask(KeyValuePair<string, RankResults> task)
int index = 0;
foreach (var winner in task.Value)
{
if (winner.Option == null)
continue;

sb.Append("[b]");
sb.Append(rankWinnerLabels[index++]);
sb.Append(":[/b] ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected override RankResults RankTask(GroupedVotesByTask task)
{
RankResult winner = GetWinningVote(voterRankings, rankedVotes);

if (winner == null)
if (winner == null || winner.Option == null)
break;

winningChoices.Add(winner);
Expand Down

0 comments on commit 99f6149

Please sign in to comment.