mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* Updated cover regex for finding cover images in archives to ignore back_cover or back-cover * Fixed an issue where Tags wouldn't save due to not pulling them from the DB. * Refactored All series to it's own lazy loaded module * Modularized Dashboard and library detail. Had to change main dashboard page to be libraries. Subject to change. * Refactored login component into registration module * Series Detail module created * Refactored nav stuff into it's own module, not lazy loaded, but self contained. * Refactored theme component into a dev only module so we don't incur load for temp testing modules * Finished off modularization code. Only missing thing is to re-introduce some dashboard functionality for library view. * Implemented a basic recommendation page for library detail
87 lines
3.4 KiB
C#
87 lines
3.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using API.Data;
|
|
using API.DTOs;
|
|
using API.Extensions;
|
|
using API.Helpers;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace API.Controllers;
|
|
|
|
public class RecommendedController : BaseApiController
|
|
{
|
|
private readonly IUnitOfWork _unitOfWork;
|
|
|
|
public RecommendedController(IUnitOfWork unitOfWork)
|
|
{
|
|
_unitOfWork = unitOfWork;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Quick Reads are series that are less than 2K pages in total.
|
|
/// </summary>
|
|
/// <param name="libraryId">Library to restrict series to</param>
|
|
/// <returns></returns>
|
|
[HttpGet("quick-reads")]
|
|
public async Task<ActionResult<PagedList<SeriesDto>>> GetQuickReads(int libraryId, [FromQuery] UserParams userParams)
|
|
{
|
|
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
|
|
|
userParams ??= new UserParams();
|
|
var series = await _unitOfWork.SeriesRepository.GetQuickReads(user.Id, libraryId, userParams);
|
|
Response.AddPaginationHeader(series.CurrentPage, series.PageSize, series.TotalCount, series.TotalPages);
|
|
return Ok(series);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Highly Rated based on other users ratings. Will pull series with ratings > 4.0, weighted by count of other users.
|
|
/// </summary>
|
|
/// <param name="libraryId">Library to restrict series to</param>
|
|
/// <returns></returns>
|
|
[HttpGet("highly-rated")]
|
|
public async Task<ActionResult<PagedList<SeriesDto>>> GetHighlyRated(int libraryId, [FromQuery] UserParams userParams)
|
|
{
|
|
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
|
|
|
userParams ??= new UserParams();
|
|
var series = await _unitOfWork.SeriesRepository.GetHighlyRated(user.Id, libraryId, userParams);
|
|
Response.AddPaginationHeader(series.CurrentPage, series.PageSize, series.TotalCount, series.TotalPages);
|
|
return Ok(series);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chooses a random genre and shows series that are in that without reading progress
|
|
/// </summary>
|
|
/// <param name="libraryId">Library to restrict series to</param>
|
|
/// <returns></returns>
|
|
[HttpGet("more-in")]
|
|
public async Task<ActionResult<PagedList<SeriesDto>>> GetMoreIn(int libraryId, int genreId, [FromQuery] UserParams userParams)
|
|
{
|
|
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
|
|
|
userParams ??= new UserParams();
|
|
var series = await _unitOfWork.SeriesRepository.GetMoreIn(user.Id, libraryId, genreId, userParams);
|
|
Response.AddPaginationHeader(series.CurrentPage, series.PageSize, series.TotalCount, series.TotalPages);
|
|
return Ok(series);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Series that are fully read by the user in no particular order
|
|
/// </summary>
|
|
/// <param name="libraryId">Library to restrict series to</param>
|
|
/// <returns></returns>
|
|
[HttpGet("rediscover")]
|
|
public async Task<ActionResult<PagedList<SeriesDto>>> GetRediscover(int libraryId, [FromQuery] UserParams userParams)
|
|
{
|
|
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
|
|
|
userParams ??= new UserParams();
|
|
var series = await _unitOfWork.SeriesRepository.GetRediscover(user.Id, libraryId, userParams);
|
|
|
|
Response.AddPaginationHeader(series.CurrentPage, series.PageSize, series.TotalCount, series.TotalPages);
|
|
return Ok(series);
|
|
}
|
|
|
|
}
|