Release Testing Time (#1785)

* Fixed a bug with getting continue point where there was a single volume unread and a later volume with chapters inside it, the chapters were being picked.

* Fixed a bug where resuming from jump key wasn't working (develop)

* Cleaned up the spacing
This commit is contained in:
Joe Milazzo 2023-02-12 13:14:13 -08:00 committed by GitHub
parent 0de927dee4
commit bdd2a0a26a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 136 additions and 34 deletions

View file

@ -62,4 +62,5 @@ public class SortComparerZeroLast : IComparer<double>
return x.CompareTo(y);
}
public static readonly SortComparerZeroLast Default = new SortComparerZeroLast();
}

View file

@ -14,4 +14,5 @@ public static class ResponseCacheProfiles
/// Instant is a very quick cache, because we can't bust based on the query params, but rather body
/// </summary>
public const string Instant = "Instant";
public const string Month = "Month";
}

View file

@ -370,7 +370,7 @@ public class SeriesController : BaseApiController
/// <param name="ageRating"></param>
/// <returns></returns>
/// <remarks>This is cached for an hour</remarks>
[ResponseCache(CacheProfileName = "Hour", VaryByQueryKeys = new [] {"ageRating"})]
[ResponseCache(CacheProfileName = "Month", VaryByQueryKeys = new [] {"ageRating"})]
[HttpGet("age-rating")]
public ActionResult<string> GetAgeRating(int ageRating)
{

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Interfaces;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace API.DTOs;

View file

@ -482,18 +482,17 @@ public class ReaderService : IReaderService
var volumeChapters = volumes
.Where(v => v.Number != 0)
.SelectMany(v => v.Chapters)
//.OrderBy(c => float.Parse(c.Number))
.ToList();
// NOTE: If volume 1 has chapter 1 and volume 2 is just chapter 0 due to being a full volume file, then this fails
// If there are any volumes that have progress, return those. If not, move on.
var currentlyReadingChapter = volumeChapters
.OrderBy(c => double.Parse(c.Range), _chapterSortComparer)
.FirstOrDefault(chapter => chapter.PagesRead < chapter.Pages);
.FirstOrDefault(chapter => chapter.PagesRead < chapter.Pages && chapter.PagesRead > 0);
if (currentlyReadingChapter != null) return currentlyReadingChapter;
// Order with volume 0 last so we prefer the natural order
return FindNextReadingChapter(volumes.OrderBy(v => v.Number, new SortComparerZeroLast()).SelectMany(v => v.Chapters).ToList());
return FindNextReadingChapter(volumes.OrderBy(v => v.Number, SortComparerZeroLast.Default).SelectMany(v => v.Chapters).ToList());
}
private static ChapterDto FindNextReadingChapter(IList<ChapterDto> volumeChapters)
@ -511,7 +510,14 @@ public class ReaderService : IReaderService
var lastChapter = chaptersWithProgress.ElementAt(last);
if (lastChapter.PagesRead < lastChapter.Pages)
{
return chaptersWithProgress.ElementAt(last);
return lastChapter;
}
// If the last chapter didn't fit, then we need the next chapter without any progress
var firstChapterWithoutProgress = volumeChapters.FirstOrDefault(c => c.PagesRead == 0);
if (firstChapterWithoutProgress != null)
{
return firstChapterWithoutProgress;
}
// chaptersWithProgress are all read, then we need to get the next chapter that doesn't have progress

View file

@ -105,12 +105,6 @@ public class StatisticService : IStatisticService
.ToListAsync();
// var averageReadingTimePerWeek = _context.AppUserProgresses
// .Where(p => p.AppUserId == userId)
// .Join(_context.Chapter, p => p.ChapterId, c => c.Id,
// (p, c) => (p.PagesRead / (float) c.Pages) * c.AvgHoursToRead)
// .Average() / 7.0;
var averageReadingTimePerWeek = _context.AppUserProgresses
.Where(p => p.AppUserId == userId)
.Join(_context.Chapter, p => p.ChapterId, c => c.Id,
@ -168,8 +162,6 @@ public class StatisticService : IStatisticService
.ToListAsync();
}
public async Task<IEnumerable<StatCount<PublicationStatus>>> GetPublicationCount()
{
return await _context.SeriesMetadata
@ -196,7 +188,6 @@ public class StatisticService : IStatisticService
.ToListAsync();
}
public async Task<ServerStatisticsDto> GetServerStatistics()
{
var mostActiveUsers = _context.AppUserProgresses

View file

@ -60,10 +60,22 @@ public class Startup
services.AddControllers(options =>
{
options.CacheProfiles.Add(ResponseCacheProfiles.Images,
options.CacheProfiles.Add(ResponseCacheProfiles.Instant,
new CacheProfile()
{
Duration = 60,
Duration = 30,
Location = ResponseCacheLocation.None,
});
options.CacheProfiles.Add(ResponseCacheProfiles.FiveMinute,
new CacheProfile()
{
Duration = 60 * 5,
Location = ResponseCacheLocation.None,
});
options.CacheProfiles.Add(ResponseCacheProfiles.TenMinute,
new CacheProfile()
{
Duration = 60 * 10,
Location = ResponseCacheLocation.None,
NoStore = false
});
@ -74,30 +86,25 @@ public class Startup
Location = ResponseCacheLocation.None,
NoStore = false
});
options.CacheProfiles.Add(ResponseCacheProfiles.TenMinute,
new CacheProfile()
{
Duration = 60 * 10,
Location = ResponseCacheLocation.None,
NoStore = false
});
options.CacheProfiles.Add(ResponseCacheProfiles.FiveMinute,
new CacheProfile()
{
Duration = 60 * 5,
Location = ResponseCacheLocation.None,
});
options.CacheProfiles.Add(ResponseCacheProfiles.Statistics,
new CacheProfile()
{
Duration = 60 * 60 * 6,
Location = ResponseCacheLocation.None,
});
options.CacheProfiles.Add(ResponseCacheProfiles.Instant,
options.CacheProfiles.Add(ResponseCacheProfiles.Images,
new CacheProfile()
{
Duration = 30,
Duration = 60,
Location = ResponseCacheLocation.None,
NoStore = false
});
options.CacheProfiles.Add(ResponseCacheProfiles.Month,
new CacheProfile()
{
Duration = TimeSpan.FromDays(30).Seconds,
Location = ResponseCacheLocation.Client,
NoStore = false
});
});
services.Configure<ForwardedHeadersOptions>(options =>