Stats Fix & Library Bulk Actions (#3209)
Co-authored-by: Fesaa <77553571+Fesaa@users.noreply.github.com> Co-authored-by: Weblate (bot) <hosted@weblate.org> Co-authored-by: Gregory.Open <gregory.open@proton.me> Co-authored-by: Mateusz <mateuszvx8.96@gmail.com> Co-authored-by: majora2007 <kavitareader@gmail.com> Co-authored-by: 無情天 <kofzhanganguo@126.com>
This commit is contained in:
parent
894b49bb76
commit
857e419e4e
77 changed files with 72523 additions and 30914 deletions
|
|
@ -698,21 +698,23 @@ public class ReaderService : IReaderService
|
|||
{
|
||||
var minHours = Math.Max((int) Math.Round((wordCount / MinWordsPerHour)), 0);
|
||||
var maxHours = Math.Max((int) Math.Round((wordCount / MaxWordsPerHour)), 0);
|
||||
|
||||
return new HourEstimateRangeDto
|
||||
{
|
||||
MinHours = Math.Min(minHours, maxHours),
|
||||
MaxHours = Math.Max(minHours, maxHours),
|
||||
AvgHours = (int) Math.Round((wordCount / AvgWordsPerHour))
|
||||
AvgHours = wordCount / AvgWordsPerHour
|
||||
};
|
||||
}
|
||||
|
||||
var minHoursPages = Math.Max((int) Math.Round((pageCount / MinPagesPerMinute / 60F)), 0);
|
||||
var maxHoursPages = Math.Max((int) Math.Round((pageCount / MaxPagesPerMinute / 60F)), 0);
|
||||
|
||||
return new HourEstimateRangeDto
|
||||
{
|
||||
MinHours = Math.Min(minHoursPages, maxHoursPages),
|
||||
MaxHours = Math.Max(minHoursPages, maxHoursPages),
|
||||
AvgHours = (int) Math.Round((pageCount / AvgPagesPerMinute / 60F))
|
||||
AvgHours = pageCount / AvgPagesPerMinute / 60F
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -808,6 +810,7 @@ public class ReaderService : IReaderService
|
|||
{
|
||||
switch(libraryType)
|
||||
{
|
||||
case LibraryType.Image:
|
||||
case LibraryType.Manga:
|
||||
return "Chapter" + (includeSpace ? " " : string.Empty);
|
||||
case LibraryType.Comic:
|
||||
|
|
|
|||
|
|
@ -595,7 +595,6 @@ public class StatisticService : IStatisticService
|
|||
.Contains(c.Id))
|
||||
})
|
||||
.OrderByDescending(d => d.Chapters.Sum(c => c.AvgHoursToRead))
|
||||
.Take(5)
|
||||
.ToList();
|
||||
|
||||
|
||||
|
|
@ -615,16 +614,17 @@ public class StatisticService : IStatisticService
|
|||
chapterLibLookup.Add(cl.ChapterId, cl.LibraryId);
|
||||
}
|
||||
|
||||
var user = new Dictionary<int, Dictionary<LibraryType, long>>();
|
||||
var user = new Dictionary<int, Dictionary<LibraryType, float>>();
|
||||
foreach (var userChapter in topUsersAndReadChapters)
|
||||
{
|
||||
if (!user.ContainsKey(userChapter.User.Id)) user.Add(userChapter.User.Id, new Dictionary<LibraryType, long>());
|
||||
if (!user.ContainsKey(userChapter.User.Id)) user.Add(userChapter.User.Id, []);
|
||||
var libraryTimes = user[userChapter.User.Id];
|
||||
|
||||
foreach (var chapter in userChapter.Chapters)
|
||||
{
|
||||
var library = libraries.First(l => l.Id == chapterLibLookup[chapter.Id]);
|
||||
if (!libraryTimes.ContainsKey(library.Type)) libraryTimes.Add(library.Type, 0L);
|
||||
libraryTimes.TryAdd(library.Type, 0f);
|
||||
|
||||
var existingHours = libraryTimes[library.Type];
|
||||
libraryTimes[library.Type] = existingHours + chapter.AvgHoursToRead;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -421,6 +421,12 @@ public class TaskScheduler : ITaskScheduler
|
|||
BackgroundJob.Enqueue(() => _scannerService.ScanSeries(seriesId, forceUpdate));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates TimeToRead and bytes
|
||||
/// </summary>
|
||||
/// <param name="libraryId"></param>
|
||||
/// <param name="seriesId"></param>
|
||||
/// <param name="forceUpdate"></param>
|
||||
public void AnalyzeFilesForSeries(int libraryId, int seriesId, bool forceUpdate = false)
|
||||
{
|
||||
if (HasAlreadyEnqueuedTask("WordCountAnalyzerService", "ScanSeries", [libraryId, seriesId, forceUpdate]))
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
|
|||
chapter.MinHoursToRead = est.MinHours;
|
||||
chapter.MaxHoursToRead = est.MaxHours;
|
||||
chapter.AvgHoursToRead = est.AvgHours;
|
||||
|
||||
foreach (var file in chapter.Files)
|
||||
{
|
||||
UpdateFileAnalysis(file);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue