mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Merge branch 'develop' of github.com:Kareadita/Kavita into develop
This commit is contained in:
commit
c3132f0067
8
.github/workflows/nightly-docker.yml
vendored
8
.github/workflows/nightly-docker.yml
vendored
@ -1,9 +1,7 @@
|
|||||||
name: Build Nightly Docker
|
name: Build Nightly Docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches:
|
|
||||||
- 'develop'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@ -13,6 +11,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Check Out Repo
|
- name: Check Out Repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: develop
|
||||||
|
|
||||||
- name: NodeJS to Compile WebUI
|
- name: NodeJS to Compile WebUI
|
||||||
uses: actions/setup-node@v2.1.5
|
uses: actions/setup-node@v2.1.5
|
||||||
@ -82,7 +82,7 @@ jobs:
|
|||||||
uses: rjstone/discord-webhook-notify@v1
|
uses: rjstone/discord-webhook-notify@v1
|
||||||
with:
|
with:
|
||||||
severity: info
|
severity: info
|
||||||
description:
|
description: ${{ github.event.body }}
|
||||||
details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated'
|
details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated'
|
||||||
text: A new nightly build has been released for docker.
|
text: A new nightly build has been released for docker.
|
||||||
webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }}
|
webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }}
|
||||||
|
87
.github/workflows/sonar-scan.yml
vendored
87
.github/workflows/sonar-scan.yml
vendored
@ -2,14 +2,42 @@ name: .NET Build Test and Sonar Scan
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, develop ]
|
branches: '**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main, develop ]
|
branches: [ main, develop ]
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build and Scan
|
name: Build .Net
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup .NET Core
|
||||||
|
uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: 5.0.100
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: dotnet restore
|
||||||
|
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.11
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: csproj
|
||||||
|
path: Kavita.Common/Kavita.Common.csproj
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Install Sonar & Test
|
||||||
|
needs: build
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
@ -52,7 +80,7 @@ jobs:
|
|||||||
New-Item -Path .\.sonar\scanner -ItemType Directory
|
New-Item -Path .\.sonar\scanner -ItemType Directory
|
||||||
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
|
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
|
||||||
|
|
||||||
- name: Build and analyze
|
- name: Sonar Scan
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
@ -64,3 +92,56 @@ jobs:
|
|||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: dotnet test --no-restore --verbosity normal
|
run: dotnet test --no-restore --verbosity normal
|
||||||
|
|
||||||
|
version:
|
||||||
|
name: Bump version on Develop push
|
||||||
|
needs: [ build, test ]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup .NET Core
|
||||||
|
uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: 5.0.100
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: dotnet restore
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build --configuration Release --no-restore
|
||||||
|
|
||||||
|
- name: Bump versions
|
||||||
|
uses: SiqiLu/dotnet-bump-version@master
|
||||||
|
with:
|
||||||
|
version_files: Kavita.Common/Kavita.Common.csproj
|
||||||
|
github_token: ${{ secrets.REPO_GHA_PAT }}
|
||||||
|
|
||||||
|
develop:
|
||||||
|
name: Trigger Nightly Docker if Develop push
|
||||||
|
needs: [ build, test, version ]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: If Push to Develop, Trigger Docker Stable
|
||||||
|
uses: benc-uk/workflow-dispatch@v1
|
||||||
|
with:
|
||||||
|
workflow: Build Nightly Docker
|
||||||
|
token: ${{ secrets.REPO_GHA_PAT }}
|
||||||
|
|
||||||
|
stable:
|
||||||
|
name: Trigger Stable Docker if Main push
|
||||||
|
needs: [ build, test ]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: If Push to Main, Trigger Docker Stable
|
||||||
|
uses: benc-uk/workflow-dispatch@v1
|
||||||
|
with:
|
||||||
|
workflow: Build Stable Docker
|
||||||
|
token: ${{ secrets.REPO_GHA_PAT }}
|
||||||
|
8
.github/workflows/stable-docker.yml
vendored
8
.github/workflows/stable-docker.yml
vendored
@ -1,9 +1,7 @@
|
|||||||
name: Build Stable Docker
|
name: Build Stable Docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches:
|
|
||||||
- 'main'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@ -12,6 +10,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Check Out Repo
|
- name: Check Out Repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
|
||||||
- name: NodeJS to Compile WebUI
|
- name: NodeJS to Compile WebUI
|
||||||
uses: actions/setup-node@v2.1.5
|
uses: actions/setup-node@v2.1.5
|
||||||
@ -99,7 +99,7 @@ jobs:
|
|||||||
uses: rjstone/discord-webhook-notify@v1
|
uses: rjstone/discord-webhook-notify@v1
|
||||||
with:
|
with:
|
||||||
severity: info
|
severity: info
|
||||||
description:
|
description: ${{ github.event.body }}
|
||||||
details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated'
|
details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated'
|
||||||
text: A new stable build has been released for docker.
|
text: A new stable build has been released for docker.
|
||||||
webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }}
|
webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }}
|
@ -168,8 +168,17 @@ namespace API.Controllers
|
|||||||
[HttpPost("in-progress")]
|
[HttpPost("in-progress")]
|
||||||
public async Task<ActionResult<IEnumerable<SeriesDto>>> GetInProgress(FilterDto filterDto, [FromQuery] UserParams userParams, [FromQuery] int libraryId = 0)
|
public async Task<ActionResult<IEnumerable<SeriesDto>>> GetInProgress(FilterDto filterDto, [FromQuery] UserParams userParams, [FromQuery] int libraryId = 0)
|
||||||
{
|
{
|
||||||
|
// NOTE: This has to be done manually like this due to the DisinctBy requirement
|
||||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
||||||
return Ok((await _unitOfWork.SeriesRepository.GetInProgress(user.Id, libraryId, userParams, filterDto)).DistinctBy(s => s.Name));
|
var results = await _unitOfWork.SeriesRepository.GetInProgress(user.Id, libraryId, userParams, filterDto);
|
||||||
|
|
||||||
|
var listResults = results.DistinctBy(s => s.Name).Skip((userParams.PageNumber - 1) * userParams.PageSize)
|
||||||
|
.Take(userParams.PageSize).ToList();
|
||||||
|
var pagedList = new PagedList<SeriesDto>(listResults, listResults.Count, userParams.PageNumber, userParams.PageSize);
|
||||||
|
|
||||||
|
Response.AddPaginationHeader(pagedList.CurrentPage, pagedList.PageSize, pagedList.TotalCount, pagedList.TotalPages);
|
||||||
|
|
||||||
|
return Ok(pagedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = "RequireAdminRole")]
|
[Authorize(Policy = "RequireAdminRole")]
|
||||||
|
@ -323,7 +323,6 @@ namespace API.Data
|
|||||||
|
|
||||||
var allQuery = _context.Series
|
var allQuery = _context.Series
|
||||||
.Where(s => userLibraries.Contains(s.LibraryId) && formats.Contains(s.Format))
|
.Where(s => userLibraries.Contains(s.LibraryId) && formats.Contains(s.Format))
|
||||||
.AsNoTracking()
|
|
||||||
.OrderByDescending(s => s.Created)
|
.OrderByDescending(s => s.Created)
|
||||||
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
||||||
.AsNoTracking();
|
.AsNoTracking();
|
||||||
@ -333,7 +332,6 @@ namespace API.Data
|
|||||||
|
|
||||||
var query = _context.Series
|
var query = _context.Series
|
||||||
.Where(s => s.LibraryId == libraryId && formats.Contains(s.Format))
|
.Where(s => s.LibraryId == libraryId && formats.Contains(s.Format))
|
||||||
.AsNoTracking()
|
|
||||||
.OrderByDescending(s => s.Created)
|
.OrderByDescending(s => s.Created)
|
||||||
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
||||||
.AsNoTracking();
|
.AsNoTracking();
|
||||||
@ -349,48 +347,46 @@ namespace API.Data
|
|||||||
/// <param name="userParams">Pagination information</param>
|
/// <param name="userParams">Pagination information</param>
|
||||||
/// <param name="filter">Optional (default null) filter on query</param>
|
/// <param name="filter">Optional (default null) filter on query</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<PagedList<SeriesDto>> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter)
|
public async Task<IEnumerable<SeriesDto>> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter)
|
||||||
{
|
{
|
||||||
var formats = filter.GetSqlFilter();
|
var formats = filter.GetSqlFilter();
|
||||||
var series = _context.Series
|
IList<int> userLibraries;
|
||||||
.Where(s => formats.Contains(s.Format))
|
|
||||||
.Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new
|
|
||||||
{
|
|
||||||
Series = s,
|
|
||||||
PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id).Sum(s1 => s1.PagesRead),
|
|
||||||
progress.AppUserId,
|
|
||||||
LastModified = _context.AppUserProgresses.Where(p => p.Id == progress.Id).Max(p => p.LastModified)
|
|
||||||
}).AsNoTracking();
|
|
||||||
if (libraryId == 0)
|
if (libraryId == 0)
|
||||||
{
|
{
|
||||||
var userLibraries = _context.Library
|
userLibraries = _context.Library
|
||||||
.Include(l => l.AppUsers)
|
.Include(l => l.AppUsers)
|
||||||
.Where(library => library.AppUsers.Any(user => user.Id == userId))
|
.Where(library => library.AppUsers.Any(user => user.Id == userId))
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Select(library => library.Id)
|
.Select(library => library.Id)
|
||||||
.ToList();
|
.ToList();
|
||||||
series = series.Where(s => s.AppUserId == userId
|
|
||||||
&& s.PagesRead > 0
|
|
||||||
&& s.PagesRead < s.Series.Pages
|
|
||||||
&& userLibraries.Contains(s.Series.LibraryId)
|
|
||||||
&& formats.Contains(s.Series.Format));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
series = series.Where(s => s.AppUserId == userId
|
userLibraries = new List<int>() {libraryId};
|
||||||
&& s.PagesRead > 0
|
|
||||||
&& s.PagesRead < s.Series.Pages
|
|
||||||
&& s.Series.LibraryId == libraryId
|
|
||||||
&& formats.Contains(s.Series.Format));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var retSeries = series
|
var series = _context.Series
|
||||||
|
.Where(s => formats.Contains(s.Format) && userLibraries.Contains(s.LibraryId))
|
||||||
|
.Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new
|
||||||
|
{
|
||||||
|
Series = s,
|
||||||
|
PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id && s1.AppUserId == userId).Sum(s1 => s1.PagesRead),
|
||||||
|
progress.AppUserId,
|
||||||
|
LastModified = _context.AppUserProgresses.Where(p => p.Id == progress.Id && p.AppUserId == userId).Max(p => p.LastModified)
|
||||||
|
})
|
||||||
|
.AsNoTracking();
|
||||||
|
|
||||||
|
var retSeries = series.Where(s => s.AppUserId == userId
|
||||||
|
&& s.PagesRead > 0
|
||||||
|
&& s.PagesRead < s.Series.Pages)
|
||||||
.OrderByDescending(s => s.LastModified)
|
.OrderByDescending(s => s.LastModified)
|
||||||
.Select(s => s.Series)
|
.Select(s => s.Series)
|
||||||
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
||||||
|
.AsSplitQuery()
|
||||||
.AsNoTracking();
|
.AsNoTracking();
|
||||||
|
|
||||||
return await PagedList<SeriesDto>.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize);
|
// Pagination does not work for this query as when we pull the data back, we get multiple rows of the same series. See controller for pagination code
|
||||||
|
return await retSeries.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SeriesMetadataDto> GetSeriesMetadata(int seriesId)
|
public async Task<SeriesMetadataDto> GetSeriesMetadata(int seriesId)
|
||||||
|
@ -7,7 +7,7 @@ namespace API.Extensions
|
|||||||
{
|
{
|
||||||
public static class FilterDtoExtensions
|
public static class FilterDtoExtensions
|
||||||
{
|
{
|
||||||
private static IList<MangaFormat> _allFormats = Enum.GetValues<MangaFormat>();
|
private static readonly IList<MangaFormat> AllFormats = Enum.GetValues<MangaFormat>();
|
||||||
|
|
||||||
public static IList<MangaFormat> GetSqlFilter(this FilterDto filter)
|
public static IList<MangaFormat> GetSqlFilter(this FilterDto filter)
|
||||||
{
|
{
|
||||||
@ -19,10 +19,7 @@ namespace API.Extensions
|
|||||||
(MangaFormat) format
|
(MangaFormat) format
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
return AllFormats;
|
||||||
{
|
|
||||||
return _allFormats;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace API.Interfaces
|
|||||||
|
|
||||||
Task<byte[]> GetVolumeCoverImageAsync(int volumeId);
|
Task<byte[]> GetVolumeCoverImageAsync(int volumeId);
|
||||||
Task<byte[]> GetSeriesCoverImageAsync(int seriesId);
|
Task<byte[]> GetSeriesCoverImageAsync(int seriesId);
|
||||||
Task<PagedList<SeriesDto>> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter);
|
Task<IEnumerable<SeriesDto>> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter);
|
||||||
Task<PagedList<SeriesDto>> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter);
|
Task<PagedList<SeriesDto>> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter);
|
||||||
Task<SeriesMetadataDto> GetSeriesMetadata(int seriesId);
|
Task<SeriesMetadataDto> GetSeriesMetadata(int seriesId);
|
||||||
Task<PagedList<SeriesDto>> GetSeriesDtoForCollectionAsync(int collectionId, int userId, UserParams userParams);
|
Task<PagedList<SeriesDto>> GetSeriesDtoForCollectionAsync(int collectionId, int userId, UserParams userParams);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<Company>kavitareader.com</Company>
|
<Company>kavitareader.com</Company>
|
||||||
<Product>Kavita</Product>
|
<Product>Kavita</Product>
|
||||||
<AssemblyVersion>0.4.3.6</AssemblyVersion>
|
<AssemblyVersion>0.4.3.9</AssemblyVersion>
|
||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user