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

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

Closed
gunr2171 opened this issue May 27, 2016 · 2 comments
Closed

Comments

@gunr2171
Copy link
Member

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
Copy link
Contributor

ArcticEcho commented May 27, 2016

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 gunr2171 added this to the Single Source of Truth milestone Jun 1, 2016
@gunr2171
Copy link
Member Author

gunr2171 commented Jun 1, 2016

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

@gunr2171 gunr2171 closed this as completed Jun 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants