Browse Source

add timings for jf episode loading and saving during update

pull/2752/head
Jason Dove 7 months ago
parent
commit
825f1b12e7
No known key found for this signature in database
  1. 13
      ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs

13
ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs

@ -175,7 +175,11 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository @@ -175,7 +175,11 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository
MediaItemScanResult<JellyfinEpisode> result;
if (existingState.Etag != item.Etag || deepScan)
{
JellyfinEpisode existing = await dbContext.JellyfinEpisodes
JellyfinEpisode existing;
using (ScanProfiler.Measure("DB Ep Upd Load"))
{
existing = await dbContext.JellyfinEpisodes
.TagWithCallSite()
.Include(e => e.EpisodeMetadata).ThenInclude(em => em.Artwork)
.Include(e => e.EpisodeMetadata).ThenInclude(em => em.Guids)
@ -191,10 +195,12 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository @@ -191,10 +195,12 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository
.SingleAsync(s => s.Id == existingId, cancellationToken);
await dbContext.Entry(existing).Reference(e => e.Season).LoadAsync(cancellationToken);
}
await UpdateEpisode(dbContext, existing, item, cancellationToken);
result = new MediaItemScanResult<JellyfinEpisode>(existing) { IsAdded = false, IsUpdated = true };
result = new MediaItemScanResult<JellyfinEpisode>(existing)
{ IsAdded = false, IsUpdated = true };
}
else
{
@ -799,6 +805,8 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository @@ -799,6 +805,8 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository
JellyfinEpisode existing,
JellyfinEpisode incoming,
CancellationToken cancellationToken)
{
using (ScanProfiler.Measure("DB Ep Upd Save"))
{
// library path is used for search indexing later
incoming.LibraryPathId = existing.LibraryPathId;
@ -932,6 +940,7 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository @@ -932,6 +940,7 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository
await dbContext.SaveChangesAsync(cancellationToken);
}
}
private static async Task<Either<BaseError, MediaItemScanResult<JellyfinShow>>> AddShow(
TvContext dbContext,

Loading…
Cancel
Save