Co-authored-by: Zeoic <zeorgaming@gmail.com>
Co-authored-by: Fesaa <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
Joe Milazzo 2025-03-01 17:17:57 -06:00 committed by GitHub
parent b38400c092
commit 0ffe0228e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 339 additions and 115 deletions

View file

@ -213,9 +213,10 @@ public class ExternalSeriesMetadataRepository : IExternalSeriesMetadataRepositor
{
return await _context.Series
.Where(s => !ExternalMetadataService.NonEligibleLibraryTypes.Contains(s.Library.Type))
.WhereIf(includeStaleData, s => s.ExternalSeriesMetadata == null || s.ExternalSeriesMetadata.ValidUntilUtc < DateTime.UtcNow)
.Where(s => s.ExternalSeriesMetadata == null || s.ExternalSeriesMetadata.ValidUntilUtc == DateTime.MinValue)
.Where(s => s.Library.AllowMetadataMatching)
.WhereIf(includeStaleData, s => s.ExternalSeriesMetadata == null || s.ExternalSeriesMetadata.ValidUntilUtc < DateTime.UtcNow)
.Where(s => s.ExternalSeriesMetadata == null || s.ExternalSeriesMetadata.AniListId == 0)
.Where(s => !s.IsBlacklisted && !s.DontMatch)
.OrderByDescending(s => s.Library.Type)
.ThenBy(s => s.NormalizedName)
.Select(s => s.Id)
@ -229,6 +230,7 @@ public class ExternalSeriesMetadataRepository : IExternalSeriesMetadataRepositor
.Include(s => s.Library)
.Include(s => s.ExternalSeriesMetadata)
.Where(s => !ExternalMetadataService.NonEligibleLibraryTypes.Contains(s.Library.Type))
.Where(s => s.Library.AllowMetadataMatching)
.FilterMatchState(filter.MatchStateOption)
.OrderBy(s => s.NormalizedName)
.ProjectTo<ManageMatchSeriesDto>(_mapper.ConfigurationProvider)

View file

@ -18,6 +18,7 @@ using Kavita.Common.Extensions;
using Microsoft.EntityFrameworkCore;
namespace API.Data.Repositories;
#nullable enable
[Flags]
public enum LibraryIncludes
@ -260,7 +261,7 @@ public class LibraryRepository : ILibraryRepository
public async Task<IList<LanguageDto>> GetAllLanguagesForLibrariesAsync(List<int>? libraryIds)
{
var ret = await _context.Series
.WhereIf(libraryIds is {Count: > 0} , s => libraryIds.Contains(s.LibraryId))
.WhereIf(libraryIds is {Count: > 0} , s => libraryIds!.Contains(s.LibraryId))
.Select(s => s.Metadata.Language)
.AsSplitQuery()
.AsNoTracking()

View file

@ -19,11 +19,13 @@ public interface IScrobbleRepository
void Attach(ScrobbleError error);
void Remove(ScrobbleEvent evt);
void Remove(IEnumerable<ScrobbleEvent> events);
void Remove(IEnumerable<ScrobbleError> errors);
void Update(ScrobbleEvent evt);
Task<IList<ScrobbleEvent>> GetByEvent(ScrobbleEventType type, bool isProcessed = false);
Task<IList<ScrobbleEvent>> GetProcessedEvents(int daysAgo);
Task<bool> Exists(int userId, int seriesId, ScrobbleEventType eventType);
Task<IEnumerable<ScrobbleErrorDto>> GetScrobbleErrors();
Task<IList<ScrobbleError>> GetAllScrobbleErrorsForSeries(int seriesId);
Task ClearScrobbleErrors();
Task<bool> HasErrorForSeries(int seriesId);
Task<ScrobbleEvent?> GetEvent(int userId, int seriesId, ScrobbleEventType eventType);
@ -66,6 +68,11 @@ public class ScrobbleRepository : IScrobbleRepository
_context.ScrobbleEvent.RemoveRange(events);
}
public void Remove(IEnumerable<ScrobbleError> errors)
{
_context.ScrobbleError.RemoveRange(errors);
}
public void Update(ScrobbleEvent evt)
{
_context.Entry(evt).State = EntityState.Modified;
@ -113,6 +120,13 @@ public class ScrobbleRepository : IScrobbleRepository
.ToListAsync();
}
public async Task<IList<ScrobbleError>> GetAllScrobbleErrorsForSeries(int seriesId)
{
return await _context.ScrobbleError
.Where(e => e.SeriesId == seriesId)
.ToListAsync();
}
public async Task ClearScrobbleErrors()
{
_context.ScrobbleError.RemoveRange(_context.ScrobbleError);
@ -161,4 +175,5 @@ public class ScrobbleRepository : IScrobbleRepository
return await _context.ScrobbleEvent.Where(e => e.SeriesId == seriesId)
.ToListAsync();
}
}

View file

@ -276,18 +276,18 @@ public static class Seed
await context.SaveChangesAsync();
// Port, IpAddresses and LoggingLevel are managed in appSettings.json. Update the DB values to match
context.ServerSetting.First(s => s.Key == ServerSettingKey.Port).Value =
(await context.ServerSetting.FirstAsync(s => s.Key == ServerSettingKey.Port)).Value =
Configuration.Port + string.Empty;
context.ServerSetting.First(s => s.Key == ServerSettingKey.IpAddresses).Value =
(await context.ServerSetting.FirstAsync(s => s.Key == ServerSettingKey.IpAddresses)).Value =
Configuration.IpAddresses;
context.ServerSetting.First(s => s.Key == ServerSettingKey.CacheDirectory).Value =
(await context.ServerSetting.FirstAsync(s => s.Key == ServerSettingKey.CacheDirectory)).Value =
directoryService.CacheDirectory + string.Empty;
context.ServerSetting.First(s => s.Key == ServerSettingKey.BackupDirectory).Value =
(await context.ServerSetting.FirstAsync(s => s.Key == ServerSettingKey.BackupDirectory)).Value =
DirectoryService.BackupDirectory + string.Empty;
context.ServerSetting.First(s => s.Key == ServerSettingKey.CacheSize).Value =
(await context.ServerSetting.FirstAsync(s => s.Key == ServerSettingKey.CacheSize)).Value =
Configuration.CacheSize + string.Empty;
await context.SaveChangesAsync();
await context.SaveChangesAsync();
}
public static async Task SeedMetadataSettings(DataContext context)