From 77f8d765906b7f161ffdd04f30ae9b682cecdb52 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Thu, 21 May 2020 22:01:20 +0100 Subject: [PATCH] Fixed #3421 --- .../Jobs/Ombi/RefreshMetadata.cs | 22 ++++++++++--------- src/Ombi.Store/Repository/BaseRepository.cs | 6 ++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs b/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs index 55d09894e..c5e86cdb7 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs @@ -1,7 +1,9 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Ombi.Api.Emby; using Ombi.Api.TheMovieDb; @@ -83,13 +85,13 @@ namespace Ombi.Schedule.Jobs.Ombi private async Task StartPlex() { // Ensure we check that we have not linked this item to a request - var allMovies = _plexRepo.GetAll().Where(x => - x.Type == PlexMediaTypeEntity.Movie && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null)); + var allMovies = await _plexRepo.GetAll().Where(x => + x.Type == PlexMediaTypeEntity.Movie && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync(); await StartPlexMovies(allMovies); // Now Tv - var allTv = _plexRepo.GetAll().Where(x => - x.Type == PlexMediaTypeEntity.Show && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)); + var allTv = await _plexRepo.GetAll().Where(x => + x.Type == PlexMediaTypeEntity.Show && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync(); await StartPlexTv(allTv); } @@ -100,7 +102,7 @@ namespace Ombi.Schedule.Jobs.Ombi await StartEmbyTv(); } - private async Task StartPlexTv(IQueryable allTv) + private async Task StartPlexTv(List allTv) { foreach (var show in allTv) { @@ -138,8 +140,8 @@ namespace Ombi.Schedule.Jobs.Ombi private async Task StartEmbyTv() { - var allTv = _embyRepo.GetAll().Where(x => - x.Type == EmbyMediaType.Series && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue() || !x.TvDbId.HasValue())); + var allTv = await _embyRepo.GetAll().Where(x => + x.Type == EmbyMediaType.Series && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue() || !x.TvDbId.HasValue())).ToListAsync(); foreach (var show in allTv) { @@ -171,7 +173,7 @@ namespace Ombi.Schedule.Jobs.Ombi } } - private async Task StartPlexMovies(IQueryable allMovies) + private async Task StartPlexMovies(List allMovies) { foreach (var movie in allMovies) { @@ -203,8 +205,8 @@ namespace Ombi.Schedule.Jobs.Ombi private async Task StartEmbyMovies(EmbySettings settings) { - var allMovies = _embyRepo.GetAll().Where(x => - x.Type == EmbyMediaType.Movie && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue())); + var allMovies = await _embyRepo.GetAll().Where(x => + x.Type == EmbyMediaType.Movie && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue())).ToListAsync(); foreach (var movie in allMovies) { movie.ImdbId.HasValue(); diff --git a/src/Ombi.Store/Repository/BaseRepository.cs b/src/Ombi.Store/Repository/BaseRepository.cs index 2df4d3467..175f0a84b 100644 --- a/src/Ombi.Store/Repository/BaseRepository.cs +++ b/src/Ombi.Store/Repository/BaseRepository.cs @@ -80,7 +80,7 @@ namespace Ombi.Store.Repository public async Task ExecuteSql(string sql) { - await _ctx.Database.ExecuteSqlCommandAsync(sql); + await _ctx.Database.ExecuteSqlRawAsync(sql); } protected async Task InternalSaveChanges() @@ -96,10 +96,10 @@ namespace Ombi.Store.Repository var result = await policy.ExecuteAndCaptureAsync(async () => { - using (var tran = await _ctx.Database.BeginTransactionAsync()) + //using (var tran = await _ctx.Database.BeginTransactionAsync()) { var r = await _ctx.SaveChangesAsync(); - tran.Commit(); + //tran.Commit(); return r; } });