Read Only Account Changes + Fixes from last PR (#3453)
This commit is contained in:
parent
41c346d5e6
commit
a8144a1d3e
28 changed files with 193 additions and 38 deletions
|
|
@ -89,7 +89,9 @@ public class StatisticService : IStatisticService
|
|||
|
||||
var lastActive = await _context.AppUserProgresses
|
||||
.Where(p => p.AppUserId == userId)
|
||||
.MaxAsync(p => p.LastModified);
|
||||
.Select(p => p.LastModified)
|
||||
.DefaultIfEmpty()
|
||||
.MaxAsync();
|
||||
|
||||
|
||||
// First get the total pages per library
|
||||
|
|
@ -127,12 +129,23 @@ public class StatisticService : IStatisticService
|
|||
|
||||
var earliestReadDate = await _context.AppUserProgresses
|
||||
.Where(p => p.AppUserId == userId)
|
||||
.MinAsync(p => p.Created);
|
||||
.Select(p => p.Created)
|
||||
.DefaultIfEmpty()
|
||||
.MinAsync();
|
||||
|
||||
if (earliestReadDate == DateTime.MinValue)
|
||||
{
|
||||
averageReadingTimePerWeek = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var timeDifference = DateTime.Now - earliestReadDate;
|
||||
var deltaWeeks = (int)Math.Ceiling(timeDifference.TotalDays / 7);
|
||||
|
||||
averageReadingTimePerWeek /= deltaWeeks;
|
||||
}
|
||||
|
||||
var timeDifference = DateTime.Now - earliestReadDate;
|
||||
var deltaWeeks = (int)Math.Ceiling(timeDifference.TotalDays / 7);
|
||||
|
||||
averageReadingTimePerWeek /= deltaWeeks;
|
||||
|
||||
|
||||
return new UserReadStatistics()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue