SO-Close-Vote-Reviewers / SOCVR-Chatbot

Chatbot (lovingly named Closey) for the SO Close Vote Reviewers Chat Room
GNU General Public License v2.0
16 stars 2 forks source link

Shouldn't we use the database for the source of all data for stats? #162

Closed gunr2171 closed 8 years ago

gunr2171 commented 8 years ago

The My Stats commands starts with the following:

var tracker = (UserTracking)typeof(Program).GetField("watcher", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
var msg = new MessageBuilder();
var currentDate = DateTimeOffset.UtcNow;
var revCount = tracker.WatchedUsers[incomingChatMessage.Author.ID].CompletedReviewsCount;

var reviews = db.ReviewedItems
    .Where(x => x.ReviewerId == incomingChatMessage.Author.ID)
    .Where(x => x.ReviewedOn.Date == currentDate.Date)
    .ToList();

msg.AppendText($"You've reviewed {revCount} post{(revCount == 1 ? "" : "s")} today");

This means that we use the UserTracking class for the main number of reviews, but the database for the actual entries (audits and table).

image

I really think all of this information should be in one place: the database. If you want the number of audits you go to the database to query it.

var audits = db.ReviewedItems
    .Where(x => x.ReviewerId == incomingChatMessage.Author.ID)
    .Where(x => x.ReviewedOn.Date == currentDate.Date)
    .Where(x => x.AuditPassed != null)
    .ToList();

As long as we have two different sources of data, we are going to run into instances like this:

You've reviewed 0 posts today. The time between your first and last review today was 17 minutes and 29 seconds, averaging to a review every 5 minutes and 49 seconds.

image

Now, I know about deleted audits. If that's the case, then we still need to record it, even if we don't have all the information about it. I can make changes to the database so that the information that we don't have is not required.

@ArcticEcho what do you think about this? I would much rather have a system that says "if you want information, go ask the database."

ArcticEcho commented 8 years ago

Now, I know about deleted audits. If that's the case, then we still need to record it [...]

Sounds good. The only reason why I decided to consult the UserTracking in the first place was due to delete audits.

gunr2171 commented 8 years ago

I made issues #163, #164, and #165 to cover the parts of this process.