mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Fixed an issue where docker installs were trying to update wwwroot, when docker doesn't do reverse proxy stuff. (#1880)
Fixed a bug in reading list date calculations.
This commit is contained in:
parent
71cb26752d
commit
0617d71d6b
@ -631,6 +631,128 @@ public class ReadingListServiceTests
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region CalculateStartAndEndDates
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CalculateStartAndEndDates_ShouldBeNothing_IfNothing()
|
||||||
|
{
|
||||||
|
await ResetDb();
|
||||||
|
var s = new SeriesBuilder("Test")
|
||||||
|
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||||
|
.WithVolumes(new List<Volume>()
|
||||||
|
{
|
||||||
|
new VolumeBuilder("0")
|
||||||
|
.WithChapter(new ChapterBuilder("1")
|
||||||
|
.Build()
|
||||||
|
)
|
||||||
|
.WithChapter(new ChapterBuilder("2")
|
||||||
|
.Build()
|
||||||
|
)
|
||||||
|
.Build()
|
||||||
|
})
|
||||||
|
.Build();
|
||||||
|
_context.AppUser.Add(new AppUser()
|
||||||
|
{
|
||||||
|
UserName = "majora2007",
|
||||||
|
ReadingLists = new List<ReadingList>(),
|
||||||
|
Libraries = new List<Library>()
|
||||||
|
{
|
||||||
|
new Library()
|
||||||
|
{
|
||||||
|
Name = "Test LIb",
|
||||||
|
Type = LibraryType.Book,
|
||||||
|
Series = new List<Series>()
|
||||||
|
{
|
||||||
|
s
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||||
|
var readingList = DbFactory.ReadingList("Test");
|
||||||
|
user.ReadingLists = new List<ReadingList>()
|
||||||
|
{
|
||||||
|
readingList
|
||||||
|
};
|
||||||
|
|
||||||
|
await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 2}, readingList);
|
||||||
|
|
||||||
|
|
||||||
|
_unitOfWork.UserRepository.Update(user);
|
||||||
|
await _unitOfWork.CommitAsync();
|
||||||
|
|
||||||
|
await _readingListService.CalculateStartAndEndDates(readingList);
|
||||||
|
Assert.Equal(0, readingList.StartingMonth);
|
||||||
|
Assert.Equal(0, readingList.StartingYear);
|
||||||
|
Assert.Equal(0, readingList.EndingMonth);
|
||||||
|
Assert.Equal(0, readingList.EndingYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CalculateStartAndEndDates_ShouldBeSomething_IfChapterHasSet()
|
||||||
|
{
|
||||||
|
await ResetDb();
|
||||||
|
var s = new SeriesBuilder("Test")
|
||||||
|
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||||
|
.WithVolumes(new List<Volume>()
|
||||||
|
{
|
||||||
|
new VolumeBuilder("0")
|
||||||
|
.WithChapter(new ChapterBuilder("1")
|
||||||
|
.WithReleaseDate(new DateTime(2005, 03, 01))
|
||||||
|
.Build()
|
||||||
|
)
|
||||||
|
.WithChapter(new ChapterBuilder("2")
|
||||||
|
.WithReleaseDate(new DateTime(2002, 03, 01))
|
||||||
|
.Build()
|
||||||
|
)
|
||||||
|
.Build()
|
||||||
|
})
|
||||||
|
.Build();
|
||||||
|
_context.AppUser.Add(new AppUser()
|
||||||
|
{
|
||||||
|
UserName = "majora2007",
|
||||||
|
ReadingLists = new List<ReadingList>(),
|
||||||
|
Libraries = new List<Library>()
|
||||||
|
{
|
||||||
|
new Library()
|
||||||
|
{
|
||||||
|
Name = "Test LIb",
|
||||||
|
Type = LibraryType.Book,
|
||||||
|
Series = new List<Series>()
|
||||||
|
{
|
||||||
|
s
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||||
|
var readingList = DbFactory.ReadingList("Test");
|
||||||
|
user.ReadingLists = new List<ReadingList>()
|
||||||
|
{
|
||||||
|
readingList
|
||||||
|
};
|
||||||
|
|
||||||
|
await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 2}, readingList);
|
||||||
|
|
||||||
|
|
||||||
|
_unitOfWork.UserRepository.Update(user);
|
||||||
|
await _unitOfWork.CommitAsync();
|
||||||
|
|
||||||
|
await _readingListService.CalculateStartAndEndDates(readingList);
|
||||||
|
Assert.Equal(3, readingList.StartingMonth);
|
||||||
|
Assert.Equal(2002, readingList.StartingYear);
|
||||||
|
Assert.Equal(3, readingList.EndingMonth);
|
||||||
|
Assert.Equal(2005, readingList.EndingYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region FormatTitle
|
#region FormatTitle
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using API.Entities;
|
using API.Entities;
|
||||||
using API.Entities.Enums;
|
using API.Entities.Enums;
|
||||||
|
|
||||||
@ -21,6 +22,12 @@ public class ChapterBuilder : IEntityBuilder<Chapter>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChapterBuilder WithReleaseDate(DateTime time)
|
||||||
|
{
|
||||||
|
_chapter.ReleaseDate = time;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ChapterBuilder WithAgeRating(AgeRating rating)
|
public ChapterBuilder WithAgeRating(AgeRating rating)
|
||||||
{
|
{
|
||||||
_chapter.AgeRating = rating;
|
_chapter.AgeRating = rating;
|
||||||
|
@ -299,7 +299,7 @@ public class ReadingListService : IReadingListService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var maxReleaseDate = items.Max(item => item.Chapter.ReleaseDate);
|
var maxReleaseDate = items.Max(item => item.Chapter.ReleaseDate);
|
||||||
var minReleaseDate = items.Max(item => item.Chapter.ReleaseDate);
|
var minReleaseDate = items.Min(item => item.Chapter.ReleaseDate);
|
||||||
if (maxReleaseDate != DateTime.MinValue)
|
if (maxReleaseDate != DateTime.MinValue)
|
||||||
{
|
{
|
||||||
readingListWithItems.EndingMonth = maxReleaseDate.Month;
|
readingListWithItems.EndingMonth = maxReleaseDate.Month;
|
||||||
|
@ -364,6 +364,7 @@ public class Startup
|
|||||||
|
|
||||||
private static void UpdateBaseUrlInIndex(string baseUrl)
|
private static void UpdateBaseUrlInIndex(string baseUrl)
|
||||||
{
|
{
|
||||||
|
if (new OsInfo(Array.Empty<IOsVersionAdapter>()).IsDocker) return;
|
||||||
var htmlDoc = new HtmlDocument();
|
var htmlDoc = new HtmlDocument();
|
||||||
var indexHtmlPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "index.html");
|
var indexHtmlPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "index.html");
|
||||||
htmlDoc.Load(indexHtmlPath);
|
htmlDoc.Load(indexHtmlPath);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"name": "GPL-3.0",
|
"name": "GPL-3.0",
|
||||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||||
},
|
},
|
||||||
"version": "0.7.1.19"
|
"version": "0.7.1.20"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user