mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Small fixes (#4978)
* fix(tv-requests): 🐛 Fixed a small bug where an exception can get thrown when attempting to view TV Requests * fix(user-importer): 🐛 Fixed an issue where the cleanup wouldn't delete users #4812
This commit is contained in:
parent
3c3edf6273
commit
5bc87b3972
4 changed files with 18 additions and 6 deletions
|
@ -929,7 +929,14 @@ namespace Ombi.Core.Engine
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -6,6 +6,7 @@ using Ombi.Api.Plex;
|
|||
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 @@ namespace Ombi.Schedule.Tests
|
|||
|
||||
await _subject.Execute(null);
|
||||
|
||||
_mocker.Verify<OmbiUserManager>(x => x.DeleteAsync(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
|
||||
_mocker.Verify<IUserDeletionEngine>(x => x.DeleteUser(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -401,7 +402,7 @@ namespace Ombi.Schedule.Tests
|
|||
|
||||
await _subject.Execute(null);
|
||||
|
||||
_mocker.Verify<OmbiUserManager>(x => x.DeleteAsync(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
|
||||
_mocker.Verify<IUserDeletionEngine>(x => x.DeleteUser(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
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<PlexUserImporter> log,
|
||||
ISettingsService<PlexSettings> plexSettings, ISettingsService<UserManagementSettings> ums, INotificationHubService notificationHubService)
|
||||
ISettingsService<PlexSettings> plexSettings, ISettingsService<UserManagementSettings> ums, INotificationHubService notificationHubService,
|
||||
IUserDeletionEngine userDeletionEngine)
|
||||
{
|
||||
_api = api;
|
||||
_userManager = um;
|
||||
|
@ -28,6 +30,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
_plexSettings = plexSettings;
|
||||
_userManagementSettings = ums;
|
||||
_notification = notificationHubService;
|
||||
_userDeletionEngine = userDeletionEngine;
|
||||
_plexSettings.ClearCache();
|
||||
_userManagementSettings.ClearCache();
|
||||
}
|
||||
|
@ -38,7 +41,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||
private readonly ISettingsService<UserManagementSettings> _userManagementSettings;
|
||||
private readonly INotificationHubService _notification;
|
||||
|
||||
private readonly IUserDeletionEngine _userDeletionEngine;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
|
@ -90,7 +93,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue