/// <summary> /// Construct vote output per task for scored votes. /// </summary> /// <param name="votesInTask">The group of votes falling under a task.</param> /// <param name="token">Cancellation token.</param> private void ConstructScoredOutput(VotesGroupedByTask votesInTask, IEnumerable <CompactVote> compactVotesInTask) { bool multiline = votesInTask.Any(a => a.Key.Lines.Count > 1); if (displayMode == DisplayMode.Compact || displayMode == DisplayMode.CompactNoVoters) { var orderedResults = compactVotesInTask .OrderByDescending(a => a.Voters.GetScore().lowerMargin) .ThenBy(a => a.CurrentLine.CleanContent); foreach (var result in orderedResults) { var flattened = result.GetFlattenedCompactVote(); foreach (var vote in flattened) { var(score, average, lowerMargin) = vote.Voters.GetScore(); sb.AppendLine(vote.ToOutputString($"{score}%")); if (displayMode != DisplayMode.CompactNoVoters) { AddCompactNormalVoteVoters(vote); } } if (!(quest.PartitionMode == PartitionMode.ByLine || quest.PartitionMode == PartitionMode.ByLineTask)) { sb.AppendLine(); } } } else { var voteResults = votesInTask.Select(v => new { vote = v, score = v.Value.GetScore() }); var orderedResults = voteResults .OrderByDescending(a => a.score.lowerMargin) .ThenByDescending(a => a.score.average) .ThenBy(a => a.vote.Key.First().CleanContent); foreach (var result in orderedResults) { VoteStorageEntry resultVote = result.vote; var resultScore = result.score; var(entryVote, entryStorage) = resultVote; AddScoreVoteSupport(resultScore); AddScoreVoteDisplay(resultVote, resultScore); AddVoterCount(entryStorage.GetNonRankUserCount()); AddNonRankVoters(entryStorage); sb.AppendLine(); } } }
/// <summary> /// Construct vote output per task for standard votes. /// </summary> /// <param name="votesInTask">The group of votes falling under a task.</param> /// <param name="token">Cancellation token.</param> private void ConstructNormalOutput(VotesGroupedByTask votesInTask, IEnumerable <CompactVote> compactVotesInTask) { bool multiline = votesInTask.Any(a => a.Key.Lines.Count > 1); if (displayMode == DisplayMode.Compact || displayMode == DisplayMode.CompactNoVoters) { var orderedResults = compactVotesInTask .OrderByDescending(a => a.Voters.GetSupportCount()) .ThenBy(a => a.CurrentLine.CleanContent); foreach (var result in orderedResults) { var flattened = result.GetFlattenedCompactVote(); foreach (var vote in flattened) { sb.AppendLine(vote.ToOutputString(vote.Voters.GetSupportCount().ToString(CultureInfo.InvariantCulture))); if (displayMode != DisplayMode.CompactNoVoters) { AddCompactNormalVoteVoters(vote); } } if (!(quest.PartitionMode == PartitionMode.ByLine || quest.PartitionMode == PartitionMode.ByLineTask)) { sb.AppendLine(); } } } else { var voteResults = votesInTask.Select(v => new { vote = v, supportCount = v.Value.GetSupportCount() }); var orderedResults = voteResults.OrderByDescending(a => a.supportCount).ThenBy(a => a.vote.Key.First().CleanContent); foreach (var result in orderedResults) { VoteStorageEntry resultVote = result.vote; int resultSupport = result.supportCount; var(entryVote, entryStorage) = resultVote; int voterCount = entryStorage.GetNonRankUserCount(); if (voterCount != resultSupport) { AddStandardVoteSupport(resultSupport); } AddStandardVoteDisplay(resultVote, resultSupport); AddVoterCount(voterCount); AddNonRankVoters(entryStorage); sb.AppendLine(); } } }