More Bugfixes (#2989)

This commit is contained in:
Joe Milazzo 2024-06-09 13:16:11 -05:00 committed by GitHub
parent 1ae723b405
commit a3e020fe17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 579 additions and 272 deletions

View file

@ -22,6 +22,7 @@ public enum ChapterIncludes
None = 1,
Volumes = 2,
Files = 4,
People = 8
}
public interface IChapterRepository

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@ -137,6 +138,7 @@ public interface ISeriesRepository
Task<IList<Series>> GetWantToReadForUserAsync(int userId);
Task<bool> IsSeriesInWantToRead(int userId, int seriesId);
Task<Series?> GetSeriesByFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None);
Task<Series?> GetSeriesThatContainsLowestFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None);
Task<IEnumerable<Series>> GetAllSeriesByNameAsync(IList<string> normalizedNames,
int userId, SeriesIncludes includes = SeriesIncludes.None);
Task<Series?> GetFullSeriesByAnyName(string seriesName, string localizedName, int libraryId, MangaFormat format, bool withFullIncludes = true);
@ -1589,14 +1591,29 @@ public class SeriesRepository : ISeriesRepository
/// <summary>
/// Return a Series by Folder path. Null if not found.
/// </summary>
/// <param name="folder">This will be normalized in the query</param>
/// <param name="folder">This will be normalized in the query and checked against FolderPath and LowestFolderPath</param>
/// <param name="includes">Additional relationships to include with the base query</param>
/// <returns></returns>
public async Task<Series?> GetSeriesByFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None)
{
var normalized = Services.Tasks.Scanner.Parser.Parser.NormalizePath(folder);
if (string.IsNullOrEmpty(normalized)) return null;
return await _context.Series
.Where(s => s.FolderPath != null && s.FolderPath.Equals(normalized))
.Where(s => (!string.IsNullOrEmpty(s.FolderPath) && s.FolderPath.Equals(normalized) || (!string.IsNullOrEmpty(s.LowestFolderPath) && s.LowestFolderPath.Equals(normalized))))
.Includes(includes)
.SingleOrDefaultAsync();
}
public async Task<Series?> GetSeriesThatContainsLowestFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None)
{
var normalized = Services.Tasks.Scanner.Parser.Parser.NormalizePath(folder);
if (string.IsNullOrEmpty(normalized)) return null;
normalized = normalized.TrimEnd('/');
return await _context.Series
.Where(s => !string.IsNullOrEmpty(s.LowestFolderPath) && EF.Functions.Like(normalized, s.LowestFolderPath + "%"))
.Includes(includes)
.SingleOrDefaultAsync();
}