Lots of Bugfixes (#2356)
This commit is contained in:
parent
86e931dd9a
commit
226d6831df
47 changed files with 359 additions and 225 deletions
|
|
@ -107,7 +107,7 @@ public static class ApplicationServiceExtensions
|
|||
|
||||
private static void AddSqLite(this IServiceCollection services)
|
||||
{
|
||||
services.AddDbContext<DataContext>(options =>
|
||||
services.AddDbContextPool<DataContext>(options =>
|
||||
{
|
||||
options.UseSqlite("Data source=config/kavita.db");
|
||||
options.EnableDetailedErrors();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using API.Comparators;
|
||||
using API.Entities;
|
||||
|
|
@ -24,7 +25,7 @@ public static class SeriesExtensions
|
|||
if (firstVolume == null) return null;
|
||||
|
||||
var chapters = firstVolume.Chapters
|
||||
.OrderBy(c => double.Parse(c.Number), ChapterSortComparerZeroFirst.Default)
|
||||
.OrderBy(c => c.Number.AsDouble(), ChapterSortComparerZeroFirst.Default)
|
||||
.ToList();
|
||||
|
||||
if (chapters.Count > 1 && chapters.Exists(c => c.IsSpecial))
|
||||
|
|
@ -44,9 +45,9 @@ public static class SeriesExtensions
|
|||
{
|
||||
var looseLeafChapters = volumes.Where(v => $"{v.Number}" == Parser.DefaultVolume)
|
||||
.SelectMany(c => c.Chapters.Where(c => !c.IsSpecial))
|
||||
.OrderBy(c => double.Parse(c.Number), ChapterSortComparerZeroFirst.Default)
|
||||
.OrderBy(c => c.Number.AsDouble(), ChapterSortComparerZeroFirst.Default)
|
||||
.ToList();
|
||||
if (looseLeafChapters.Count > 0 && (1.0f * volumes[0].Number) > float.Parse(looseLeafChapters[0].Number))
|
||||
if (looseLeafChapters.Count > 0 && (1.0f * volumes[0].Number) > looseLeafChapters[0].Number.AsFloat())
|
||||
{
|
||||
return looseLeafChapters[0].CoverImage;
|
||||
}
|
||||
|
|
@ -56,7 +57,7 @@ public static class SeriesExtensions
|
|||
var firstLooseLeafChapter = volumes
|
||||
.Where(v => $"{v.Number}" == Parser.DefaultVolume)
|
||||
.SelectMany(v => v.Chapters)
|
||||
.OrderBy(c => double.Parse(c.Number), ChapterSortComparerZeroFirst.Default)
|
||||
.OrderBy(c => c.Number.AsDouble(), ChapterSortComparerZeroFirst.Default)
|
||||
.FirstOrDefault(c => !c.IsSpecial);
|
||||
|
||||
return firstLooseLeafChapter?.CoverImage ?? firstVolume.CoverImage;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace API.Extensions;
|
||||
|
||||
|
|
@ -22,4 +23,14 @@ public static class StringExtensions
|
|||
if (string.IsNullOrEmpty(value)) return string.Empty;
|
||||
return Services.Tasks.Scanner.Parser.Parser.Normalize(value);
|
||||
}
|
||||
|
||||
public static float AsFloat(this string value)
|
||||
{
|
||||
return float.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static double AsDouble(this string value)
|
||||
{
|
||||
return double.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue