Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Don't calc the stats if there's no data
Browse files Browse the repository at this point in the history
Add a % of users in the room that participated in reviewing today.
  • Loading branch information
ArcticEcho committed Mar 20, 2016
1 parent 7baa740 commit 8dbd64a
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -35,6 +35,12 @@ public override void RunAction(Message incomingChatMessage, Room chatRoom)
.Where(x => x.ReviewedOn.Date == DateTimeOffset.UtcNow.Date)
.ToList();

if (reviewsInDbToday.Count == 0)
{
chatRoom.PostReplyOrThrow(incomingChatMessage, "I don't have enough data to produce those stats.");
return;
}

var reviewerCount = reviewsInDbToday
.Select(x => x.ReviewerId)
.Distinct()
Expand All @@ -44,7 +50,9 @@ public override void RunAction(Message incomingChatMessage, Room chatRoom)

var percentage = Math.Round(reviewItemCount * 1.0 / stats.ReviewsToday * 100, 2);

var message = $"{reviewerCount} members have processed {reviewItemCount} review items today, which accounts for {percentage}% of all cv reviews today.";
var usersPercentage = Math.Round((double)reviewerCount / chatRoom.PingableUsers.Count(x => x.Reputation >= 3000));

var message = $"{reviewerCount} members ({usersPercentage}% of this room's able reviewers) have processed {reviewItemCount} review items today, which accounts for {percentage}% of all CV reviews today.";

chatRoom.PostReplyOrThrow(incomingChatMessage, message);
}
Expand Down

0 comments on commit 8dbd64a

Please sign in to comment.