-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inaccurate weekly episode count #345
Conversation
Could you explain what you mean by "weekly episode count"? Is it the estimated last-aired episode number? How does this change fix the issue? For starters, let's get a couple of relatively minor issues out of the way:
The main issue is that the If we need more resolution, then we shouldn't be using |
The issue I was trying to fix is the "You've watched X episodes in the last week" count in the Now Playing tab. Basically on December 30th I had ~70 episodes watched in the last week (didn't check the 31st), but come January 1st I had only 8 episodes watched, which isn't right since I continually watched episodes throughout the previous week. I manually did the calculation for the 9th to last item in my history which did come out to 8 days ago but was actually on the 28th. I suspect a similar issue with a smaller gap can happen when the month changes. Probably more obvious during a leap year on March 1st. Quick example: If the date is 2017-01-01, everything from 2016-12-28 and older is out of the 1 week range. The issue comes from the way we convert Dates to days.
Thinking about this, it might actually be a better idea to not save the seconds at all since someone can just come along and change the year, month, or day value which won't update the stored seconds. So everytime we do the subtraction we have to recalculate the seconds value. I don't think that is a huge performance issue. I don't handle having a month of 0 and if it is,
|
I see, thanks for the explanation. There are two main approaches to implementing a date class:
Mixing them both is not necessary, unless you have to maintain a cache to improve performance. For our purposes, performance is not the primary concern. If I remember correctly, the reason I went for the field-based approach and used that rather crude algorithm was to accommodate unknown values. While I was aware that it could cause problems, I haven't encountered this particular issue until now. Handling dates and time is a lot more complicated than it appears to be, so it's generally not a good idea to roll your own code. As I mentioned in #316, I intend to use a proper date library in the future. That being said, a proper date class won't allow partial dates such as For now, changing the conversion algorithm might suffice at fixing this issue. Could you provide a solution that would work for both full and partial dates, without introducing the Edit: I'm playing around with the date library now, and it seems it's going to work. |
This should fix the issue discussed in #345.
Since you seem to have this working using the date library I'll go ahead and close this. |
After the new year I noticed the weekly episode count was off. Just made the Date class track the seconds to easily count the number of days.