From 9840077c5c9fc899f6bb90e4642df4b8de4faa52 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 3 Jul 2023 20:11:15 +0100 Subject: [PATCH 1/3] =?UTF-8?q?fix(tv-requests):=20=F0=9F=90=9B=20Fixed=20?= =?UTF-8?q?a=20small=20bug=20where=20an=20exception=20can=20get=20thrown?= =?UTF-8?q?=20when=20attempting=20to=20view=20TV=20Requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Ombi.Core/Engine/TvRequestEngine.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index 16866d0dd..a586156aa 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -929,7 +929,14 @@ private void CheckForPlayed(HideResult shouldHide, List childRequ var playedCount = playedEpisodes.Count(); var toWatchCount = requestedEpisodes.Count(); - request.RequestedUserPlayedProgress = 100 * playedCount / toWatchCount; + if (playedCount == 0 || toWatchCount == 0) + { + request.RequestedUserPlayedProgress = 0; + } + else + { + request.RequestedUserPlayedProgress = 100 * playedCount / toWatchCount; + } } } From 46397cbda6911bd52f17043238a160e8f77b35c2 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 3 Jul 2023 20:11:38 +0100 Subject: [PATCH 2/3] =?UTF-8?q?fix(user-importer):=20=F0=9F=90=9B=20Fixed?= =?UTF-8?q?=20an=20issue=20where=20the=20cleanup=20wouldn't=20delete=20use?= =?UTF-8?q?rs=20#4812?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Ombi.Core/Engine/UserDeletionEngine.cs | 1 + src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Ombi.Core/Engine/UserDeletionEngine.cs b/src/Ombi.Core/Engine/UserDeletionEngine.cs index 1c8fd63ca..eef7bd2f1 100644 --- a/src/Ombi.Core/Engine/UserDeletionEngine.cs +++ b/src/Ombi.Core/Engine/UserDeletionEngine.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; +using Microsoft.VisualBasic; using Ombi.Core.Authentication; using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs index 3b931b586..68a7026a3 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging; using Ombi.Api.Plex; using Ombi.Core.Authentication; +using Ombi.Core.Engine; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; using Ombi.Helpers; @@ -20,7 +21,8 @@ namespace Ombi.Schedule.Jobs.Plex public class PlexUserImporter : IPlexUserImporter { public PlexUserImporter(IPlexApi api, OmbiUserManager um, ILogger log, - ISettingsService plexSettings, ISettingsService ums, INotificationHubService notificationHubService) + ISettingsService plexSettings, ISettingsService ums, INotificationHubService notificationHubService, + IUserDeletionEngine userDeletionEngine) { _api = api; _userManager = um; @@ -28,6 +30,7 @@ public PlexUserImporter(IPlexApi api, OmbiUserManager um, ILogger _plexSettings; private readonly ISettingsService _userManagementSettings; private readonly INotificationHubService _notification; - + private readonly IUserDeletionEngine _userDeletionEngine; public async Task Execute(IJobExecutionContext job) { @@ -90,7 +93,7 @@ public async Task Execute(IJobExecutionContext job) foreach (var ombiUser in missingUsers) { _log.LogInformation("Deleting user {0} not found in Plex Server.", ombiUser.UserName); - await _userManager.DeleteAsync(ombiUser); + await _userDeletionEngine.DeleteUser(ombiUser); } } From b96892b14e4d4abb73cd83cd6eaaeedff977ed6f Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 3 Jul 2023 20:43:00 +0100 Subject: [PATCH 3/3] Fixed tests --- src/Ombi.Schedule.Tests/PlexUserImporterTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ombi.Schedule.Tests/PlexUserImporterTests.cs b/src/Ombi.Schedule.Tests/PlexUserImporterTests.cs index 62d058d19..39443ea55 100644 --- a/src/Ombi.Schedule.Tests/PlexUserImporterTests.cs +++ b/src/Ombi.Schedule.Tests/PlexUserImporterTests.cs @@ -6,6 +6,7 @@ using Ombi.Api.Plex.Models; using Ombi.Api.Plex.Models.Friends; using Ombi.Core.Authentication; +using Ombi.Core.Engine; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; using Ombi.Helpers; @@ -365,7 +366,7 @@ public async Task Import_Cleanup_Missing_Plex_Users() await _subject.Execute(null); - _mocker.Verify(x => x.DeleteAsync(It.Is(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once); + _mocker.Verify(x => x.DeleteUser(It.Is(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once); } [Test] @@ -401,7 +402,7 @@ public async Task Import_Cleanup_Missing_Plex_Admin() await _subject.Execute(null); - _mocker.Verify(x => x.DeleteAsync(It.Is(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once); + _mocker.Verify(x => x.DeleteUser(It.Is(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once); } } }