public static double GetApprovalPercentage(this PromotionCampaignSummary campaign) { var totalApprovals = campaign.CommentCounts .Where(x => x.Key == PromotionSentiment.Approve) .Select(x => x.Value) .Sum(); double totalVotes = GetTotalVotes(campaign); return(totalApprovals / totalVotes); }
public static TimeSpan GetTimeUntilCampaignCanBeClosed(this PromotionCampaignSummary campaign) { return(campaign.CreateAction.Created.Add(CampaignAcceptCooldown) - DateTimeOffset.Now); }
public static int GetNumberOfOppositions(this PromotionCampaignSummary campaign) { return(campaign.CommentCounts .Where(x => x.Key == PromotionSentiment.Oppose) .Sum(x => x.Value)); }
public static int GetTotalVotes(this PromotionCampaignSummary campaign) { return(campaign.CommentCounts .Select(x => x.Value) .Sum()); }
/// <summary> /// Get the total count of comments that were not abstaining /// </summary> public static int GetTotalVotes(this PromotionCampaignSummary campaign) { return(campaign.CommentCounts .Where(x => x.Key != PromotionSentiment.Abstain) .Sum(x => x.Value)); }