From 41e411c484f6408abb2031693964e6e98ba60eac Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 18 Oct 2018 08:14:21 +0100 Subject: [PATCH 01/20] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f3cafffb..591757f08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## (unreleased) +## v3.0.3919 (2018-10-18) ### **New Features** From 7a3d7f6547c0186ab9877dab6b7b5883d35233a8 Mon Sep 17 00:00:00 2001 From: Jamie Date: Sat, 20 Oct 2018 01:03:49 +0100 Subject: [PATCH 02/20] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 591757f08..02c5ed1cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.0.3923 (2018-10-20) + +- Fixed #2601 [TidusJar] + ## v3.0.3919 (2018-10-18) ### **New Features** From 2a863ef57454adfe316b6bbb3d2518c759eba17b Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 20 Oct 2018 09:53:31 -0400 Subject: [PATCH 03/20] Update Readme for Lidarr :) --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cfc0ad23c..6347a8a5f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ___ # Features Here are some of the features Ombi V3 has: * Now working without crashes on Linux. -* Lets users request Movies and TV Shows (whether it being the entire series, an entire season, or even single episodes.) +* Lets users request Movies, Music, and TV Shows (whether it being the entire series, an entire season, or even single episodes.) * Easily manage your requests * User management system (supports plex.tv, Emby and local accounts) * A landing page that will give you the availability of your Plex/Emby server and also add custom notification text to inform your users of downtime. @@ -50,6 +50,7 @@ We integrate with the following applications: * Emby * Sonarr * Radarr +* Lidarr * DogNzb * Couch Potato @@ -87,6 +88,7 @@ We are planning to bring back these features in V3 but for now you can find a li | DogNzb | Yes | No | | Issues | Yes | Yes | | Headphones | No | Yes | +| Lidarr | Yes | No | # Feature Requests Feature requests are handled on FeatHub. From 50bd130782c3451c4a3f7dcbf0575db4a54e9797 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 25 Oct 2018 21:45:14 +0100 Subject: [PATCH 04/20] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f7a2e5db..321098722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## v3.0.3923 (2018-10-20) +## V3.0.3945 (2018-10-25) - Fixed #2601 [TidusJar] From b1e6fd313ba51646d31c53fb3bbf39af17105007 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Wed, 14 Nov 2018 20:06:50 +0000 Subject: [PATCH 05/20] !wip started on the request queue --- .../Jobs/Ombi/ResendFailedRequests.cs | 19 +++++++++++++++++++ src/Ombi.Store/Entities/RequestQueue.cs | 14 ++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs create mode 100644 src/Ombi.Store/Entities/RequestQueue.cs diff --git a/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs b/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs new file mode 100644 index 000000000..1e7b8d760 --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs @@ -0,0 +1,19 @@ +using System.Threading.Tasks; +using Ombi.Store.Entities; +using Ombi.Store.Repository; + +namespace Ombi.Schedule.Jobs.Ombi +{ + public class ResendFailedRequests + { + public ResendFailedRequests(IRepository queue, IMovieSender movieSender) + { + + } + + public async Task Start() + { + + } + } +} \ No newline at end of file diff --git a/src/Ombi.Store/Entities/RequestQueue.cs b/src/Ombi.Store/Entities/RequestQueue.cs new file mode 100644 index 000000000..980bfca31 --- /dev/null +++ b/src/Ombi.Store/Entities/RequestQueue.cs @@ -0,0 +1,14 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Ombi.Store.Entities +{ + [Table("RequestQueue")] + public class RequestQueue : Entity + { + public int RequestId { get; set; } + public RequestType Type { get; set; } + public DateTime Dts { get; set; } + public DateTime Completed { get; set; } + } +} \ No newline at end of file From 04dcc8f1be57204d38e3eb508694f081f3524b5f Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 23 Nov 2018 20:31:15 +0000 Subject: [PATCH 06/20] !changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1684273b..be6d012ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,8 @@ # Changelog -## V3.0.3945 (2018-10-25) +## v3.0.3988 (2018-11-23) -- Fixed #2601 [TidusJar] -## v3.0.3919 (2018-10-18) ### **New Features** @@ -14,6 +12,8 @@ ### **Fixes** +- Fixed #2601 [TidusJar] + - Made the subscribe/unsubscribe button more obvious on the UI #2309. [Jamie] - Fixed #2603. [Jamie] From 207fbe0a8f08836120a13bdb1e285199dd7a7e7c Mon Sep 17 00:00:00 2001 From: TidusJar Date: Mon, 3 Dec 2018 20:54:01 +0000 Subject: [PATCH 07/20] Save to the request queue !wip --- src/Ombi.Core/Senders/MovieSender.cs | 72 +++++++++++++++---------- src/Ombi.Core/Senders/MusicSender.cs | 40 ++++++++++++-- src/Ombi.Core/Senders/TvSender.cs | 30 ++++++++++- src/Ombi.Store/Entities/RequestQueue.cs | 2 + 4 files changed, 110 insertions(+), 34 deletions(-) diff --git a/src/Ombi.Core/Senders/MovieSender.cs b/src/Ombi.Core/Senders/MovieSender.cs index 8b89ef7bb..844caced3 100644 --- a/src/Ombi.Core/Senders/MovieSender.cs +++ b/src/Ombi.Core/Senders/MovieSender.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -19,7 +20,7 @@ namespace Ombi.Core.Senders { public MovieSender(ISettingsService radarrSettings, IRadarrApi api, ILogger log, ISettingsService dogSettings, IDogNzbApi dogApi, ISettingsService cpSettings, - ICouchPotatoApi cpApi, IRepository userProfiles) + ICouchPotatoApi cpApi, IRepository userProfiles, IRepository requestQueue, INotificationHelper notify) { RadarrSettings = radarrSettings; RadarrApi = api; @@ -29,6 +30,8 @@ namespace Ombi.Core.Senders CouchPotatoSettings = cpSettings; CouchPotatoApi = cpApi; _userProfiles = userProfiles; + _requestQueuRepository = requestQueue; + _notificationHelper = notify; } private ISettingsService RadarrSettings { get; } @@ -39,39 +42,52 @@ namespace Ombi.Core.Senders private ISettingsService CouchPotatoSettings { get; } private ICouchPotatoApi CouchPotatoApi { get; } private readonly IRepository _userProfiles; + private readonly IRepository _requestQueuRepository; + private readonly INotificationHelper _notificationHelper; public async Task Send(MovieRequests model) { - var cpSettings = await CouchPotatoSettings.GetSettingsAsync(); - //var watcherSettings = await WatcherSettings.GetSettingsAsync(); - var radarrSettings = await RadarrSettings.GetSettingsAsync(); - if (radarrSettings.Enabled) + try { - return await SendToRadarr(model, radarrSettings); - } - var dogSettings = await DogNzbSettings.GetSettingsAsync(); - if (dogSettings.Enabled) - { - await SendToDogNzb(model, dogSettings); - return new SenderResult + var cpSettings = await CouchPotatoSettings.GetSettingsAsync(); + //var watcherSettings = await WatcherSettings.GetSettingsAsync(); + var radarrSettings = await RadarrSettings.GetSettingsAsync(); + if (radarrSettings.Enabled) { - Success = true, - Sent = true, - }; - } + return await SendToRadarr(model, radarrSettings); + } - if (cpSettings.Enabled) + var dogSettings = await DogNzbSettings.GetSettingsAsync(); + if (dogSettings.Enabled) + { + await SendToDogNzb(model, dogSettings); + return new SenderResult + { + Success = true, + Sent = true, + }; + } + + if (cpSettings.Enabled) + { + return await SendToCp(model, cpSettings, cpSettings.DefaultProfileId); + } + } + catch (Exception e) { - return await SendToCp(model, cpSettings, cpSettings.DefaultProfileId); + Log.LogError(e, "Error when seing movie to DVR app, added to the request queue"S); + await _requestQueuRepository.Add(new RequestQueue + { + Dts = DateTime.UtcNow, + Error = e.Message, + RequestId = model.Id, + Type = RequestType.Movie, + RetryCount = 0 + }); + _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); } - //if (watcherSettings.Enabled) - //{ - // return SendToWatcher(model, watcherSettings); - //} - - return new SenderResult { Success = true, @@ -93,9 +109,9 @@ namespace Ombi.Core.Senders private async Task SendToRadarr(MovieRequests model, RadarrSettings settings) { - + var qualityToUse = int.Parse(settings.DefaultQualityProfile); - + var rootFolderPath = settings.DefaultRootPath; var profiles = await _userProfiles.GetAll().FirstOrDefaultAsync(x => x.UserId == model.RequestedUserId); @@ -150,7 +166,7 @@ namespace Ombi.Core.Senders // Search for it if (!settings.AddOnly) { - await RadarrApi.MovieSearch(new[] {existingMovie.id}, settings.ApiKey, settings.FullUri); + await RadarrApi.MovieSearch(new[] { existingMovie.id }, settings.ApiKey, settings.FullUri); } return new SenderResult { Success = true, Sent = true }; diff --git a/src/Ombi.Core/Senders/MusicSender.cs b/src/Ombi.Core/Senders/MusicSender.cs index 60e4ca6ee..235ea3db8 100644 --- a/src/Ombi.Core/Senders/MusicSender.cs +++ b/src/Ombi.Core/Senders/MusicSender.cs @@ -1,37 +1,67 @@ using System; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; using Ombi.Api.Lidarr; using Ombi.Api.Lidarr.Models; using Ombi.Api.Radarr; using Ombi.Core.Settings; using Ombi.Helpers; using Ombi.Settings.Settings.Models.External; +using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository; using Serilog; +using ILogger = Microsoft.Extensions.Logging.ILogger; namespace Ombi.Core.Senders { public class MusicSender : IMusicSender { - public MusicSender(ISettingsService lidarr, ILidarrApi lidarrApi) + public MusicSender(ISettingsService lidarr, ILidarrApi lidarrApi, ILogger log, + IRepository requestQueue, INotificationHelper notify) { _lidarrSettings = lidarr; _lidarrApi = lidarrApi; + _log = log; + _requestQueueRepository = requestQueue; + _notificationHelper = notify; } private readonly ISettingsService _lidarrSettings; private readonly ILidarrApi _lidarrApi; + private readonly ILogger _log; + private readonly IRepository _requestQueueRepository; + private readonly INotificationHelper _notificationHelper; public async Task Send(AlbumRequest model) { - var settings = await _lidarrSettings.GetSettingsAsync(); - if (settings.Enabled) + try { - return await SendToLidarr(model, settings); + var settings = await _lidarrSettings.GetSettingsAsync(); + if (settings.Enabled) + { + return await SendToLidarr(model, settings); + } + + return new SenderResult { Success = false, Sent = false, Message = "Lidarr is not enabled" }; } + catch (Exception e) + { + _log.LogError(e, "Exception thrown when sending a music to DVR app, added to the request queue"); + await _requestQueueRepository.Add(new RequestQueue + { + Dts = DateTime.UtcNow, + Error = e.Message, + RequestId = model.Id, + Type = RequestType.Album, + RetryCount = 0 + }); + _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + } + - return new SenderResult { Success = false, Sent = false, Message = "Lidarr is not enabled" }; + return new SenderResult { Success = false, Sent = false, Message = "Something went wrong!" }; } private async Task SendToLidarr(AlbumRequest model, LidarrSettings settings) diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index e48e54c1a..c590e52ca 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -23,7 +23,7 @@ namespace Ombi.Core.Senders { public TvSender(ISonarrApi sonarrApi, ILogger log, ISettingsService sonarrSettings, ISettingsService dog, IDogNzbApi dogApi, ISettingsService srSettings, - ISickRageApi srApi, IRepository userProfiles) + ISickRageApi srApi, IRepository userProfiles, IRepository requestQueue, INotificationHelper notify) { SonarrApi = sonarrApi; Logger = log; @@ -33,6 +33,8 @@ namespace Ombi.Core.Senders SickRageSettings = srSettings; SickRageApi = srApi; UserQualityProfiles = userProfiles; + _requestQueueRepository = requestQueue; + _notificationHelper = notify; } private ISonarrApi SonarrApi { get; } @@ -43,9 +45,15 @@ namespace Ombi.Core.Senders private ISettingsService DogNzbSettings { get; } private ISettingsService SickRageSettings { get; } private IRepository UserQualityProfiles { get; } + private readonly IRepository _requestQueueRepository; + private readonly INotificationHelper _notificationHelper; public async Task Send(ChildRequests model) { + try + { + + var sonarr = await SonarrSettings.GetSettingsAsync(); if (sonarr.Enabled) { @@ -97,6 +105,26 @@ namespace Ombi.Core.Senders { Success = true }; + } + catch (Exception e) + { + Logger.LogError(e, "Exception thrown when sending a movie to DVR app, added to the request queue"); + await _requestQueueRepository.Add(new RequestQueue + { + Dts = DateTime.UtcNow, + Error = e.Message, + RequestId = model.Id, + Type = RequestType.TvShow, + RetryCount = 0 + }); + _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + } + + return new SenderResult + { + Success = false, + Message = "Something wen't wrong!" + }; } private async Task SendToDogNzb(ChildRequests model, DogNzbSettings settings) diff --git a/src/Ombi.Store/Entities/RequestQueue.cs b/src/Ombi.Store/Entities/RequestQueue.cs index 980bfca31..e561f9ec7 100644 --- a/src/Ombi.Store/Entities/RequestQueue.cs +++ b/src/Ombi.Store/Entities/RequestQueue.cs @@ -9,6 +9,8 @@ namespace Ombi.Store.Entities public int RequestId { get; set; } public RequestType Type { get; set; } public DateTime Dts { get; set; } + public string Error { get; set; } public DateTime Completed { get; set; } + public int RetryCount { get; set; } } } \ No newline at end of file From da5d4f0738d536c355b8f3c705bf13f15dab003e Mon Sep 17 00:00:00 2001 From: TidusJar Date: Mon, 3 Dec 2018 21:19:57 +0000 Subject: [PATCH 08/20] Finished off the job --- src/Ombi.Core/Engine/VoteEngine.cs | 4 +- src/Ombi.Core/Ombi.Core.csproj | 3 +- src/Ombi.Core/Senders/MovieSender.cs | 30 +++-- src/Ombi.Core/Senders/MusicSender.cs | 26 +++-- src/Ombi.Core/Senders/TvSender.cs | 107 ++++++++++-------- src/Ombi.Helpers/StringHelper.cs | 44 +++++++ src/Ombi.Schedule/JobSetup.cs | 6 +- .../Jobs/Ombi/IResendFailedRequests.cs | 9 ++ src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs | 47 +------- .../Jobs/Ombi/ResendFailedRequests.cs | 64 ++++++++++- src/Ombi.Schedule/Ombi.Schedule.csproj | 1 + .../Settings/Models/JobSettings.cs | 1 + .../Settings/Models/JobSettingsHelper.cs | 4 + src/Ombi.Store/Entities/RequestQueue.cs | 2 +- .../ClientApp/app/interfaces/ISettings.ts | 1 + .../app/settings/jobs/jobs.component.html | 7 ++ src/Ombi/Controllers/SettingsController.cs | 1 + 17 files changed, 238 insertions(+), 119 deletions(-) create mode 100644 src/Ombi.Schedule/Jobs/Ombi/IResendFailedRequests.cs diff --git a/src/Ombi.Core/Engine/VoteEngine.cs b/src/Ombi.Core/Engine/VoteEngine.cs index 7c4d48a6f..5c73e03d9 100644 --- a/src/Ombi.Core/Engine/VoteEngine.cs +++ b/src/Ombi.Core/Engine/VoteEngine.cs @@ -11,7 +11,7 @@ using Ombi.Core.Models; using Ombi.Core.Models.UI; using Ombi.Core.Rule.Interfaces; using Ombi.Core.Settings; -using Ombi.Schedule.Jobs.Ombi; +using Ombi.Helpers; using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; using Ombi.Store.Repository; @@ -114,7 +114,7 @@ namespace Ombi.Core.Engine foreach (var epInformation in childRequests.SeasonRequests.OrderBy(x => x.SeasonNumber)) { var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList(); - var episodeString = NewsletterJob.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); + var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}"); finalsb.Append("
"); } diff --git a/src/Ombi.Core/Ombi.Core.csproj b/src/Ombi.Core/Ombi.Core.csproj index 10e07822a..644c02515 100644 --- a/src/Ombi.Core/Ombi.Core.csproj +++ b/src/Ombi.Core/Ombi.Core.csproj @@ -20,16 +20,17 @@ + + - diff --git a/src/Ombi.Core/Senders/MovieSender.cs b/src/Ombi.Core/Senders/MovieSender.cs index 844caced3..49a6c9efa 100644 --- a/src/Ombi.Core/Senders/MovieSender.cs +++ b/src/Ombi.Core/Senders/MovieSender.cs @@ -76,16 +76,28 @@ namespace Ombi.Core.Senders } catch (Exception e) { - Log.LogError(e, "Error when seing movie to DVR app, added to the request queue"S); - await _requestQueuRepository.Add(new RequestQueue + Log.LogError(e, "Error when seing movie to DVR app, added to the request queue"); + + // Check if already in request quee + var existingQueue = await _requestQueuRepository.FirstOrDefaultAsync(x => x.RequestId == model.Id); + if (existingQueue != null) + { + existingQueue.RetryCount++; + existingQueue.Error = e.Message; + await _requestQueuRepository.SaveChangesAsync(); + } + else { - Dts = DateTime.UtcNow, - Error = e.Message, - RequestId = model.Id, - Type = RequestType.Movie, - RetryCount = 0 - }); - _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + await _requestQueuRepository.Add(new RequestQueue + { + Dts = DateTime.UtcNow, + Error = e.Message, + RequestId = model.Id, + Type = RequestType.Movie, + RetryCount = 0 + }); + _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + } } return new SenderResult diff --git a/src/Ombi.Core/Senders/MusicSender.cs b/src/Ombi.Core/Senders/MusicSender.cs index 235ea3db8..b016e76b5 100644 --- a/src/Ombi.Core/Senders/MusicSender.cs +++ b/src/Ombi.Core/Senders/MusicSender.cs @@ -49,15 +49,25 @@ namespace Ombi.Core.Senders catch (Exception e) { _log.LogError(e, "Exception thrown when sending a music to DVR app, added to the request queue"); - await _requestQueueRepository.Add(new RequestQueue + var existingQueue = await _requestQueueRepository.FirstOrDefaultAsync(x => x.RequestId == model.Id); + if (existingQueue != null) { - Dts = DateTime.UtcNow, - Error = e.Message, - RequestId = model.Id, - Type = RequestType.Album, - RetryCount = 0 - }); - _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + existingQueue.RetryCount++; + existingQueue.Error = e.Message; + await _requestQueueRepository.SaveChangesAsync(); + } + else + { + await _requestQueueRepository.Add(new RequestQueue + { + Dts = DateTime.UtcNow, + Error = e.Message, + RequestId = model.Id, + Type = RequestType.Album, + RetryCount = 0 + }); + _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + } } diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index c590e52ca..cc686aa38 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -52,72 +52,81 @@ namespace Ombi.Core.Senders { try { - - - var sonarr = await SonarrSettings.GetSettingsAsync(); - if (sonarr.Enabled) - { - var result = await SendToSonarr(model); - if (result != null) + var sonarr = await SonarrSettings.GetSettingsAsync(); + if (sonarr.Enabled) { - return new SenderResult + var result = await SendToSonarr(model); + if (result != null) { - Sent = true, - Success = true - }; + return new SenderResult + { + Sent = true, + Success = true + }; + } } - } - var dog = await DogNzbSettings.GetSettingsAsync(); - if (dog.Enabled) - { - var result = await SendToDogNzb(model, dog); - if (!result.Failure) + var dog = await DogNzbSettings.GetSettingsAsync(); + if (dog.Enabled) { + var result = await SendToDogNzb(model, dog); + if (!result.Failure) + { + return new SenderResult + { + Sent = true, + Success = true + }; + } return new SenderResult { - Sent = true, - Success = true + Message = result.ErrorMessage }; } - return new SenderResult - { - Message = result.ErrorMessage - }; - } - var sr = await SickRageSettings.GetSettingsAsync(); - if (sr.Enabled) - { - var result = await SendToSickRage(model, sr); - if (result) + var sr = await SickRageSettings.GetSettingsAsync(); + if (sr.Enabled) { + var result = await SendToSickRage(model, sr); + if (result) + { + return new SenderResult + { + Sent = true, + Success = true + }; + } return new SenderResult { - Sent = true, - Success = true + Message = "Could not send to SickRage!" }; } return new SenderResult { - Message = "Could not send to SickRage!" + Success = true }; } - return new SenderResult - { - Success = true - }; - } catch (Exception e) { Logger.LogError(e, "Exception thrown when sending a movie to DVR app, added to the request queue"); - await _requestQueueRepository.Add(new RequestQueue + // Check if already in request quee + var existingQueue = await _requestQueueRepository.FirstOrDefaultAsync(x => x.RequestId == model.Id); + if (existingQueue != null) { - Dts = DateTime.UtcNow, - Error = e.Message, - RequestId = model.Id, - Type = RequestType.TvShow, - RetryCount = 0 - }); - _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + existingQueue.RetryCount++; + existingQueue.Error = e.Message; + await _requestQueueRepository.SaveChangesAsync(); + } + else + { + await _requestQueueRepository.Add(new RequestQueue + { + Dts = DateTime.UtcNow, + Error = e.Message, + RequestId = model.Id, + Type = RequestType.TvShow, + RetryCount = 0 + }); + _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); + } } return new SenderResult @@ -171,7 +180,7 @@ namespace Ombi.Core.Senders } if (profiles.SonarrQualityProfileAnime > 0) { - qualityToUse = profiles.SonarrQualityProfileAnime; + qualityToUse = profiles.SonarrQualityProfileAnime; } } seriesType = "anime"; @@ -191,7 +200,7 @@ namespace Ombi.Core.Senders } if (profiles.SonarrQualityProfile > 0) { - qualityToUse = profiles.SonarrQualityProfile; + qualityToUse = profiles.SonarrQualityProfile; } } seriesType = "standard"; @@ -202,7 +211,7 @@ namespace Ombi.Core.Senders { qualityToUse = model.ParentRequest.QualityOverride.Value; } - + try { // Does the series actually exist? @@ -296,7 +305,7 @@ namespace Ombi.Core.Senders } } var seriesChanges = false; - + foreach (var season in model.SeasonRequests) { var sonarrSeason = sonarrEpList.Where(x => x.seasonNumber == season.SeasonNumber); diff --git a/src/Ombi.Helpers/StringHelper.cs b/src/Ombi.Helpers/StringHelper.cs index c198301fc..68a29e848 100644 --- a/src/Ombi.Helpers/StringHelper.cs +++ b/src/Ombi.Helpers/StringHelper.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Security; @@ -76,6 +77,49 @@ namespace Ombi.Helpers return -1; } + public static string BuildEpisodeList(IEnumerable orderedEpisodes) + { + var epSb = new StringBuilder(); + var previousEpisodes = new List(); + var previousEpisode = -1; + foreach (var ep in orderedEpisodes) + { + if (ep - 1 == previousEpisode) + { + // This is the next one + previousEpisodes.Add(ep); + } + else + { + if (previousEpisodes.Count > 1) + { + // End it + epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}, "); + } + else if (previousEpisodes.Count == 1) + { + epSb.Append($"{previousEpisodes.FirstOrDefault()}, "); + } + // New one + previousEpisodes.Clear(); + previousEpisodes.Add(ep); + } + previousEpisode = ep; + } + + if (previousEpisodes.Count > 1) + { + // Got some left over + epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}"); + } + else if (previousEpisodes.Count == 1) + { + epSb.Append(previousEpisodes.FirstOrDefault()); + } + + return epSb.ToString(); + } + public static string RemoveSpaces(this string str) { return str.Replace(" ", ""); diff --git a/src/Ombi.Schedule/JobSetup.cs b/src/Ombi.Schedule/JobSetup.cs index 7ce32de04..fa111d5f4 100644 --- a/src/Ombi.Schedule/JobSetup.cs +++ b/src/Ombi.Schedule/JobSetup.cs @@ -21,7 +21,7 @@ namespace Ombi.Schedule IEmbyUserImporter embyUserImporter, ISonarrSync cache, ICouchPotatoSync cpCache, ISettingsService jobsettings, ISickRageSync srSync, IRefreshMetadata refresh, INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedPlex, ILidarrArtistSync artist, - IIssuesPurge purge) + IIssuesPurge purge, IResendFailedRequests resender) { _plexContentSync = plexContentSync; _radarrSync = radarrSync; @@ -38,6 +38,7 @@ namespace Ombi.Schedule _plexRecentlyAddedSync = recentlyAddedPlex; _lidarrArtistSync = artist; _issuesPurge = purge; + _resender = resender; } private readonly IPlexContentSync _plexContentSync; @@ -55,6 +56,7 @@ namespace Ombi.Schedule private readonly INewsletterJob _newsletter; private readonly ILidarrArtistSync _lidarrArtistSync; private readonly IIssuesPurge _issuesPurge; + private readonly IResendFailedRequests _resender; public void Setup() { @@ -76,6 +78,8 @@ namespace Ombi.Schedule RecurringJob.AddOrUpdate(() => _embyUserImporter.Start(), JobSettingsHelper.UserImporter(s)); RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s)); RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s)); + RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s)); + RecurringJob.AddOrUpdate(() => _resender.Start(), JobSettingsHelper.ResendFailedRequests(s)); } diff --git a/src/Ombi.Schedule/Jobs/Ombi/IResendFailedRequests.cs b/src/Ombi.Schedule/Jobs/Ombi/IResendFailedRequests.cs new file mode 100644 index 000000000..b55c0f69b --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Ombi/IResendFailedRequests.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Ombi.Schedule.Jobs.Ombi +{ + public interface IResendFailedRequests + { + Task Start(); + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs index 472cd325b..ab0ef9578 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs @@ -677,7 +677,7 @@ namespace Ombi.Schedule.Jobs.Ombi foreach (var epInformation in results.OrderBy(x => x.SeasonNumber)) { var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList(); - var episodeString = BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); + var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}"); finalsb.Append("
"); } @@ -715,48 +715,7 @@ namespace Ombi.Schedule.Jobs.Ombi } } - public static string BuildEpisodeList(IEnumerable orderedEpisodes) - { - var epSb = new StringBuilder(); - var previousEpisodes = new List(); - var previousEpisode = -1; - foreach (var ep in orderedEpisodes) - { - if (ep - 1 == previousEpisode) - { - // This is the next one - previousEpisodes.Add(ep); - } - else - { - if (previousEpisodes.Count > 1) - { - // End it - epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}, "); - } - else if (previousEpisodes.Count == 1) - { - epSb.Append($"{previousEpisodes.FirstOrDefault()}, "); - } - // New one - previousEpisodes.Clear(); - previousEpisodes.Add(ep); - } - previousEpisode = ep; - } - - if (previousEpisodes.Count > 1) - { - // Got some left over - epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}"); - } - else if(previousEpisodes.Count == 1) - { - epSb.Append(previousEpisodes.FirstOrDefault()); - } - - return epSb.ToString(); - } + private async Task ProcessEmbyTv(HashSet embyContent, StringBuilder sb) { @@ -841,7 +800,7 @@ namespace Ombi.Schedule.Jobs.Ombi foreach (var epInformation in results.OrderBy(x => x.SeasonNumber)) { var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList(); - var episodeString = BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); + var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}"); finalsb.Append("
"); } diff --git a/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs b/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs index 1e7b8d760..bc8f93a97 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs @@ -1,19 +1,75 @@ -using System.Threading.Tasks; +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Ombi.Core; +using Ombi.Core.Senders; using Ombi.Store.Entities; using Ombi.Store.Repository; +using Ombi.Store.Repository.Requests; namespace Ombi.Schedule.Jobs.Ombi { - public class ResendFailedRequests + public class ResendFailedRequests : IResendFailedRequests { - public ResendFailedRequests(IRepository queue, IMovieSender movieSender) + public ResendFailedRequests(IRepository queue, IMovieSender movieSender, ITvSender tvSender, IMusicSender musicSender, + IMovieRequestRepository movieRepo, ITvRequestRepository tvRepo, IMusicRequestRepository music) { - + _requestQueue = queue; + _movieSender = movieSender; + _tvSender = tvSender; + _musicSender = musicSender; + _movieRequestRepository = movieRepo; + _tvRequestRepository = tvRepo; + _musicRequestRepository = music; } + private readonly IRepository _requestQueue; + private readonly IMovieSender _movieSender; + private readonly ITvSender _tvSender; + private readonly IMusicSender _musicSender; + private readonly IMovieRequestRepository _movieRequestRepository; + private readonly ITvRequestRepository _tvRequestRepository; + private readonly IMusicRequestRepository _musicRequestRepository; + public async Task Start() { + // Get all the failed ones! + var failedRequests = _requestQueue.GetAll().Where(x => !x.Completed.HasValue); + foreach (var request in failedRequests) + { + if (request.Type == RequestType.Movie) + { + var movieRequest = await _movieRequestRepository.GetAll().FirstOrDefaultAsync(x => x.Id == request.RequestId); + var result = await _movieSender.Send(movieRequest); + if (result.Success) + { + request.Completed = DateTime.UtcNow; + await _requestQueue.SaveChangesAsync(); + } + } + if (request.Type == RequestType.TvShow) + { + var tvRequest = await _tvRequestRepository.GetChild().FirstOrDefaultAsync(x => x.Id == request.RequestId); + var result = await _tvSender.Send(tvRequest); + if (result.Success) + { + request.Completed = DateTime.UtcNow; + await _requestQueue.SaveChangesAsync(); + } + } + if (request.Type == RequestType.Album) + { + var musicRequest = await _musicRequestRepository.GetAll().FirstOrDefaultAsync(x => x.Id == request.RequestId); + var result = await _musicSender.Send(musicRequest); + if (result.Success) + { + request.Completed = DateTime.UtcNow; + await _requestQueue.SaveChangesAsync(); + } + } + } } } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Ombi.Schedule.csproj b/src/Ombi.Schedule/Ombi.Schedule.csproj index 06cc2bb49..94657e922 100644 --- a/src/Ombi.Schedule/Ombi.Schedule.csproj +++ b/src/Ombi.Schedule/Ombi.Schedule.csproj @@ -34,6 +34,7 @@ + diff --git a/src/Ombi.Settings/Settings/Models/JobSettings.cs b/src/Ombi.Settings/Settings/Models/JobSettings.cs index 8b283cdf7..46a950185 100644 --- a/src/Ombi.Settings/Settings/Models/JobSettings.cs +++ b/src/Ombi.Settings/Settings/Models/JobSettings.cs @@ -15,5 +15,6 @@ public string Newsletter { get; set; } public string LidarrArtistSync { get; set; } public string IssuesPurge { get; set; } + public string RetryRequests { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs b/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs index 4491ca27a..1aca72344 100644 --- a/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs +++ b/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs @@ -61,6 +61,10 @@ namespace Ombi.Settings.Settings.Models { return Get(s.IssuesPurge, Cron.Daily()); } + public static string ResendFailedRequests(JobSettings s) + { + return Get(s.RetryRequests, Cron.Daily(6)); + } private static string Get(string settings, string defaultCron) { diff --git a/src/Ombi.Store/Entities/RequestQueue.cs b/src/Ombi.Store/Entities/RequestQueue.cs index e561f9ec7..85f73e04b 100644 --- a/src/Ombi.Store/Entities/RequestQueue.cs +++ b/src/Ombi.Store/Entities/RequestQueue.cs @@ -10,7 +10,7 @@ namespace Ombi.Store.Entities public RequestType Type { get; set; } public DateTime Dts { get; set; } public string Error { get; set; } - public DateTime Completed { get; set; } + public DateTime? Completed { get; set; } public int RetryCount { get; set; } } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index f1934a994..7e57c0e64 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -145,6 +145,7 @@ export interface IJobSettings { plexRecentlyAddedSync: string; lidarrArtistSync: string; issuesPurge: string; + retryRequests: string; } export interface IIssueSettings extends ISettings { diff --git a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html index 1365710f0..e889c0fca 100644 --- a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html +++ b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html @@ -48,6 +48,13 @@ The Automatic Update is required + +
+ + + The Retry Requests is required + +
diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index b523250a6..338b55f21 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -520,6 +520,7 @@ namespace Ombi.Controllers j.Newsletter = j.Newsletter.HasValue() ? j.Newsletter : JobSettingsHelper.Newsletter(j); j.LidarrArtistSync = j.LidarrArtistSync.HasValue() ? j.LidarrArtistSync : JobSettingsHelper.LidarrArtistSync(j); j.IssuesPurge = j.IssuesPurge.HasValue() ? j.IssuesPurge : JobSettingsHelper.IssuePurge(j); + j.RetryRequests = j.RetryRequests.HasValue() ? j.RetryRequests : JobSettingsHelper.ResendFailedRequests(j); return j; } From 75f43260c0aff88d0a6bf7602e4af6dd3f4c0127 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Mon, 3 Dec 2018 21:36:46 +0000 Subject: [PATCH 09/20] !wip added the api --- .../Rule/Search/CouchPotatoCacheRuleTests.cs | 4 +- .../Rule/Search/RadarrCacheRuleTests.cs | 4 +- src/Ombi.Core/Ombi.Core.csproj | 1 + src/Ombi.Core/Senders/MusicSender.cs | 2 - src/Ombi.Schedule.Tests/NewsletterTests.cs | 6 +- .../20181203213532_RequestQueue.Designer.cs | 1182 +++++++++++++++++ .../Migrations/20181203213532_RequestQueue.cs | 17 + .../Migrations/OmbiContextModelSnapshot.cs | 2 +- src/Ombi/Controllers/RequestRetyController.cs | 44 + 9 files changed, 1253 insertions(+), 9 deletions(-) create mode 100644 src/Ombi.Store/Migrations/20181203213532_RequestQueue.Designer.cs create mode 100644 src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs create mode 100644 src/Ombi/Controllers/RequestRetyController.cs diff --git a/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs index 56524522b..2a8f7a520 100644 --- a/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs @@ -18,13 +18,13 @@ namespace Ombi.Core.Tests.Rule.Search [SetUp] public void Setup() { - ContextMock = new Mock>(); + ContextMock = new Mock>(); Rule = new CouchPotatoCacheRule(ContextMock.Object); } private CouchPotatoCacheRule Rule { get; set; } - private Mock> ContextMock { get; set; } + private Mock> ContextMock { get; set; } [Test] public async Task Should_ReturnApproved_WhenMovieIsInCouchPotato() diff --git a/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs index 914112d5b..94efe89a2 100644 --- a/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs @@ -15,13 +15,13 @@ namespace Ombi.Core.Tests.Rule.Search [SetUp] public void Setup() { - ContextMock = new Mock>(); + ContextMock = new Mock>(); Rule = new RadarrCacheRule(ContextMock.Object); } private RadarrCacheRule Rule { get; set; } - private Mock> ContextMock { get; set; } + private Mock> ContextMock { get; set; } [Test] public async Task Should_ReturnApproved_WhenMovieIsInRadarr() diff --git a/src/Ombi.Core/Ombi.Core.csproj b/src/Ombi.Core/Ombi.Core.csproj index 644c02515..fb1024b93 100644 --- a/src/Ombi.Core/Ombi.Core.csproj +++ b/src/Ombi.Core/Ombi.Core.csproj @@ -22,6 +22,7 @@ + diff --git a/src/Ombi.Core/Senders/MusicSender.cs b/src/Ombi.Core/Senders/MusicSender.cs index b016e76b5..76a9fc14c 100644 --- a/src/Ombi.Core/Senders/MusicSender.cs +++ b/src/Ombi.Core/Senders/MusicSender.cs @@ -4,14 +4,12 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Ombi.Api.Lidarr; using Ombi.Api.Lidarr.Models; -using Ombi.Api.Radarr; using Ombi.Core.Settings; using Ombi.Helpers; using Ombi.Settings.Settings.Models.External; using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; using Ombi.Store.Repository; -using Serilog; using ILogger = Microsoft.Extensions.Logging.ILogger; namespace Ombi.Core.Senders diff --git a/src/Ombi.Schedule.Tests/NewsletterTests.cs b/src/Ombi.Schedule.Tests/NewsletterTests.cs index 146cd97cf..f729e8899 100644 --- a/src/Ombi.Schedule.Tests/NewsletterTests.cs +++ b/src/Ombi.Schedule.Tests/NewsletterTests.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using NUnit.Framework; +using Ombi.Helpers; using static Ombi.Schedule.Jobs.Ombi.NewsletterJob; namespace Ombi.Schedule.Tests @@ -15,7 +17,7 @@ namespace Ombi.Schedule.Tests { ep.Add(i); } - var result = BuildEpisodeList(ep); + var result = StringHelper.BuildEpisodeList(ep); return result; } diff --git a/src/Ombi.Store/Migrations/20181203213532_RequestQueue.Designer.cs b/src/Ombi.Store/Migrations/20181203213532_RequestQueue.Designer.cs new file mode 100644 index 000000000..5de4398af --- /dev/null +++ b/src/Ombi.Store/Migrations/20181203213532_RequestQueue.Designer.cs @@ -0,0 +1,1182 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context; + +namespace Ombi.Store.Migrations +{ + [DbContext(typeof(OmbiContext))] + [Migration("20181203213532_RequestQueue")] + partial class RequestQueue + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.1.4-rtm-31024"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Name") + .HasMaxLength(256); + + b.Property("NormalizedName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("RoleId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider"); + + b.Property("ProviderKey"); + + b.Property("ProviderDisplayName"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId"); + + b.Property("RoleId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId"); + + b.Property("LoginProvider"); + + b.Property("Name"); + + b.Property("Value"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Type"); + + b.Property("Value"); + + b.HasKey("Id"); + + b.ToTable("ApplicationConfiguration"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Audit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditArea"); + + b.Property("AuditType"); + + b.Property("DateTime"); + + b.Property("Description"); + + b.Property("User"); + + b.HasKey("Id"); + + b.ToTable("Audit"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("TheMovieDbId"); + + b.HasKey("Id"); + + b.ToTable("CouchPotatoCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("EmbyId") + .IsRequired(); + + b.Property("ImdbId"); + + b.Property("ProviderId"); + + b.Property("TheMovieDbId"); + + b.Property("Title"); + + b.Property("TvDbId"); + + b.Property("Type"); + + b.Property("Url"); + + b.HasKey("Id"); + + b.ToTable("EmbyContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("EmbyId"); + + b.Property("EpisodeNumber"); + + b.Property("ImdbId"); + + b.Property("ParentId"); + + b.Property("ProviderId"); + + b.Property("SeasonNumber"); + + b.Property("TheMovieDbId"); + + b.Property("Title"); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("EmbyEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Content"); + + b.Property("SettingsName"); + + b.HasKey("Id"); + + b.ToTable("GlobalSettings"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("ArtistId"); + + b.Property("ForeignAlbumId"); + + b.Property("Monitored"); + + b.Property("PercentOfTracks"); + + b.Property("ReleaseDate"); + + b.Property("Title"); + + b.Property("TrackCount"); + + b.HasKey("Id"); + + b.ToTable("LidarrAlbumCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ArtistId"); + + b.Property("ArtistName"); + + b.Property("ForeignArtistId"); + + b.Property("Monitored"); + + b.HasKey("Id"); + + b.ToTable("LidarrArtistCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Agent"); + + b.Property("Enabled"); + + b.Property("Message"); + + b.Property("NotificationType"); + + b.Property("Subject"); + + b.HasKey("Id"); + + b.ToTable("NotificationTemplates"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("PlayerId"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AccessFailedCount"); + + b.Property("Alias"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Email") + .HasMaxLength(256); + + b.Property("EmailConfirmed"); + + b.Property("EmbyConnectUserId"); + + b.Property("EpisodeRequestLimit"); + + b.Property("LastLoggedIn"); + + b.Property("LockoutEnabled"); + + b.Property("LockoutEnd"); + + b.Property("MovieRequestLimit"); + + b.Property("MusicRequestLimit"); + + b.Property("NormalizedEmail") + .HasMaxLength(256); + + b.Property("NormalizedUserName") + .HasMaxLength(256); + + b.Property("PasswordHash"); + + b.Property("PhoneNumber"); + + b.Property("PhoneNumberConfirmed"); + + b.Property("ProviderUserId"); + + b.Property("SecurityStamp"); + + b.Property("TwoFactorEnabled"); + + b.Property("UserAccessToken"); + + b.Property("UserName") + .HasMaxLength(256); + + b.Property("UserType"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EpisodeNumber"); + + b.Property("GrandparentKey"); + + b.Property("Key"); + + b.Property("ParentKey"); + + b.Property("SeasonNumber"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("GrandparentKey"); + + b.ToTable("PlexEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ParentKey"); + + b.Property("PlexContentId"); + + b.Property("PlexServerContentId"); + + b.Property("SeasonKey"); + + b.Property("SeasonNumber"); + + b.HasKey("Id"); + + b.HasIndex("PlexServerContentId"); + + b.ToTable("PlexSeasonsContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("ImdbId"); + + b.Property("Key"); + + b.Property("Quality"); + + b.Property("ReleaseYear"); + + b.Property("TheMovieDbId"); + + b.Property("Title"); + + b.Property("TvDbId"); + + b.Property("Type"); + + b.Property("Url"); + + b.HasKey("Id"); + + b.ToTable("PlexServerContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("HasFile"); + + b.Property("TheMovieDbId"); + + b.HasKey("Id"); + + b.ToTable("RadarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RecentlyAddedLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("AlbumId"); + + b.Property("ContentId"); + + b.Property("ContentType"); + + b.Property("EpisodeNumber"); + + b.Property("SeasonNumber"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.ToTable("RecentlyAddedLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Approved"); + + b.Property("ArtistName"); + + b.Property("Available"); + + b.Property("Cover"); + + b.Property("Denied"); + + b.Property("DeniedReason"); + + b.Property("Disk"); + + b.Property("ForeignAlbumId"); + + b.Property("ForeignArtistId"); + + b.Property("MarkedAsApproved"); + + b.Property("MarkedAsAvailable"); + + b.Property("MarkedAsDenied"); + + b.Property("Rating"); + + b.Property("ReleaseDate"); + + b.Property("RequestType"); + + b.Property("RequestedDate"); + + b.Property("RequestedUserId"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("AlbumRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Approved"); + + b.Property("Available"); + + b.Property("Denied"); + + b.Property("DeniedReason"); + + b.Property("IssueId"); + + b.Property("MarkedAsApproved"); + + b.Property("MarkedAsAvailable"); + + b.Property("MarkedAsDenied"); + + b.Property("ParentRequestId"); + + b.Property("RequestType"); + + b.Property("RequestedDate"); + + b.Property("RequestedUserId"); + + b.Property("SeriesType"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("ParentRequestId"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Value"); + + b.HasKey("Id"); + + b.ToTable("IssueCategory"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Comment"); + + b.Property("Date"); + + b.Property("IssuesId"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("IssuesId"); + + b.HasIndex("UserId"); + + b.ToTable("IssueComments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.Property("IssueCategoryId"); + + b.Property("IssueId"); + + b.Property("ProviderId"); + + b.Property("RequestId"); + + b.Property("RequestType"); + + b.Property("ResovledDate"); + + b.Property("Status"); + + b.Property("Subject"); + + b.Property("Title"); + + b.Property("UserReportedId"); + + b.HasKey("Id"); + + b.HasIndex("IssueCategoryId"); + + b.HasIndex("IssueId"); + + b.HasIndex("UserReportedId"); + + b.ToTable("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Approved"); + + b.Property("Available"); + + b.Property("Background"); + + b.Property("Denied"); + + b.Property("DeniedReason"); + + b.Property("DigitalReleaseDate"); + + b.Property("ImdbId"); + + b.Property("IssueId"); + + b.Property("MarkedAsApproved"); + + b.Property("MarkedAsAvailable"); + + b.Property("MarkedAsDenied"); + + b.Property("Overview"); + + b.Property("PosterPath"); + + b.Property("QualityOverride"); + + b.Property("ReleaseDate"); + + b.Property("RequestType"); + + b.Property("RequestedDate"); + + b.Property("RequestedUserId"); + + b.Property("RootPathOverride"); + + b.Property("Status"); + + b.Property("TheMovieDbId"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("MovieRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EpisodeCount"); + + b.Property("RequestDate"); + + b.Property("RequestId"); + + b.Property("RequestType"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Background"); + + b.Property("ImdbId"); + + b.Property("Overview"); + + b.Property("PosterPath"); + + b.Property("QualityOverride"); + + b.Property("ReleaseDate"); + + b.Property("RootFolder"); + + b.Property("Status"); + + b.Property("Title"); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("TvRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("RequestId"); + + b.Property("RequestType"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestSubscription"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("SickRageCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EpisodeNumber"); + + b.Property("SeasonNumber"); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("SickRageEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("SonarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EpisodeNumber"); + + b.Property("HasFile"); + + b.Property("SeasonNumber"); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("SonarrEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Token"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Agent"); + + b.Property("Enabled"); + + b.Property("UserId"); + + b.Property("Value"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("RadarrQualityProfile"); + + b.Property("RadarrRootPath"); + + b.Property("SonarrQualityProfile"); + + b.Property("SonarrQualityProfileAnime"); + + b.Property("SonarrRootPath"); + + b.Property("SonarrRootPathAnime"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserQualityProfiles"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Date"); + + b.Property("Deleted"); + + b.Property("RequestId"); + + b.Property("RequestType"); + + b.Property("UserId"); + + b.Property("VoteType"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Votes"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AirDate"); + + b.Property("Approved"); + + b.Property("Available"); + + b.Property("EpisodeNumber"); + + b.Property("Requested"); + + b.Property("SeasonId"); + + b.Property("Title"); + + b.Property("Url"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId"); + + b.ToTable("EpisodeRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChildRequestId"); + + b.Property("SeasonNumber"); + + b.HasKey("Id"); + + b.HasIndex("ChildRequestId"); + + b.ToTable("SeasonRequests"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.HasOne("Ombi.Store.Entities.EmbyContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("EmbyId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("NotificationUserIds") + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent") + .WithMany("Seasons") + .HasForeignKey("PlexServerContentId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest") + .WithMany("ChildRequests") + .HasForeignKey("ParentRequestId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.HasOne("Ombi.Store.Entities.Requests.Issues", "Issues") + .WithMany("Comments") + .HasForeignKey("IssuesId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.HasOne("Ombi.Store.Entities.Requests.IssueCategory", "IssueCategory") + .WithMany() + .HasForeignKey("IssueCategoryId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests") + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.Requests.MovieRequests") + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported") + .WithMany() + .HasForeignKey("UserReportedId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("UserNotificationPreferences") + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season") + .WithMany("Episodes") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest") + .WithMany("SeasonRequests") + .HasForeignKey("ChildRequestId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs b/src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs new file mode 100644 index 000000000..cd577cc26 --- /dev/null +++ b/src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ombi.Store.Migrations +{ + public partial class RequestQueue : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs index 60927b1ed..672525b41 100644 --- a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs @@ -14,7 +14,7 @@ namespace Ombi.Store.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); + .HasAnnotation("ProductVersion", "2.1.4-rtm-31024"); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { diff --git a/src/Ombi/Controllers/RequestRetyController.cs b/src/Ombi/Controllers/RequestRetyController.cs new file mode 100644 index 000000000..34e11eb6d --- /dev/null +++ b/src/Ombi/Controllers/RequestRetyController.cs @@ -0,0 +1,44 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository; +using System.Collections.Generic; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using Ombi.Store.Entities; + +namespace Ombi.Controllers +{ + [ApiV1] + [Authorize] + [Produces("application/json")] + public class RequestRetyController : Controller + { + public RequestRetyController(IRepository requestQueue) + { + _requestQueueRepository = requestQueue; + } + + private readonly IRepository _requestQueueRepository; + + /// + /// Get's all the failed requests that are currently in the queue + /// + /// + [HttpGet] + public async Task> Categories() + { + return await _requestQueueRepository.GetAll().Where(x => !x.Completed.HasValue).ToListAsync(); + } + + [HttpDelete("{queueId:int}")] + public async Task Delete(int queueId) + { + var queueItem = await _requestQueueRepository.GetAll().FirstOrDefaultAsync(x => x.Id == queueId); + await _requestQueueRepository.Delete(queueItem); + return Ok(); + } + + } +} \ No newline at end of file From e8c6b23304e70d41809fcba2eb3391b702b87094 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Mon, 3 Dec 2018 21:44:07 +0000 Subject: [PATCH 10/20] Started on the UI !wip --- src/Ombi.DependencyInjection/IocExtensions.cs | 1 + .../app/services/requestretry.service.ts | 18 +++++++++++++ .../failedrequest.component.html | 3 +++ .../failedrequests.component.ts | 25 +++++++++++++++++++ .../app/settings/jobs/jobs.component.html | 2 +- .../ClientApp/app/settings/settings.module.ts | 3 +++ src/Ombi/Controllers/RequestRetyController.cs | 3 ++- 7 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/Ombi/ClientApp/app/services/requestretry.service.ts create mode 100644 src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html create mode 100644 src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index f5184493c..836bc4f5b 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -198,6 +198,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } diff --git a/src/Ombi/ClientApp/app/services/requestretry.service.ts b/src/Ombi/ClientApp/app/services/requestretry.service.ts new file mode 100644 index 000000000..338475609 --- /dev/null +++ b/src/Ombi/ClientApp/app/services/requestretry.service.ts @@ -0,0 +1,18 @@ +import { PlatformLocation } from "@angular/common"; +import { Injectable } from "@angular/core"; + +import { HttpClient } from "@angular/common/http"; +import { Observable } from "rxjs"; + +import { IMobileUsersViewModel } from "../interfaces"; +import { ServiceHelpers } from "./service.helpers"; + +@Injectable() +export class RequestRetryService extends ServiceHelpers { + constructor(http: HttpClient, public platformLocation: PlatformLocation) { + super(http, "/api/v1/requestretry/", platformLocation); + } + public getUserDeviceList(): Observable { + return this.http.get(`${this.url}notification/`, {headers: this.headers}); + } +} diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html new file mode 100644 index 000000000..4689eef46 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html @@ -0,0 +1,3 @@ + + + diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts new file mode 100644 index 000000000..af75a8bf1 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from "@angular/core"; +import { IAbout } from "../../interfaces/ISettings"; +import { JobService, SettingsService } from "../../services"; + +@Component({ + templateUrl: "./about.component.html", +}) +export class AboutComponent implements OnInit { + + public about: IAbout; + public newUpdate: boolean; + + constructor(private readonly settingsService: SettingsService, + private readonly jobService: JobService) { } + + public ngOnInit() { + this.settingsService.about().subscribe(x => this.about = x); + this.jobService.getCachedUpdate().subscribe(x => { + if (x === true) { + this.newUpdate = true; + } + }); + + } +} diff --git a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html index e889c0fca..f8e3bb309 100644 --- a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html +++ b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html @@ -51,7 +51,7 @@
- + The Retry Requests is required
diff --git a/src/Ombi/ClientApp/app/settings/settings.module.ts b/src/Ombi/ClientApp/app/settings/settings.module.ts index 060d42b19..e0fd90db9 100644 --- a/src/Ombi/ClientApp/app/settings/settings.module.ts +++ b/src/Ombi/ClientApp/app/settings/settings.module.ts @@ -19,6 +19,7 @@ import { CouchPotatoComponent } from "./couchpotato/couchpotato.component"; import { CustomizationComponent } from "./customization/customization.component"; import { DogNzbComponent } from "./dognzb/dognzb.component"; import { EmbyComponent } from "./emby/emby.component"; +import { FailedRequestsComponent } from "./failedrequests/failedrequests.component"; import { IssuesComponent } from "./issues/issues.component"; import { JobsComponent } from "./jobs/jobs.component"; import { LandingPageComponent } from "./landingpage/landingpage.component"; @@ -77,6 +78,7 @@ const routes: Routes = [ { path: "Newsletter", component: NewsletterComponent, canActivate: [AuthGuard] }, { path: "Lidarr", component: LidarrComponent, canActivate: [AuthGuard] }, { path: "Vote", component: VoteComponent, canActivate: [AuthGuard] }, + { path: "FailedRequests", component: FailedRequestsComponent, canActivate: [AuthGuard] }, ]; @NgModule({ @@ -130,6 +132,7 @@ const routes: Routes = [ NewsletterComponent, LidarrComponent, VoteComponent, + FailedRequestsComponent, ], exports: [ RouterModule, diff --git a/src/Ombi/Controllers/RequestRetyController.cs b/src/Ombi/Controllers/RequestRetyController.cs index 34e11eb6d..69e379838 100644 --- a/src/Ombi/Controllers/RequestRetyController.cs +++ b/src/Ombi/Controllers/RequestRetyController.cs @@ -6,12 +6,13 @@ using Ombi.Store.Repository; using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; +using Ombi.Attributes; using Ombi.Store.Entities; namespace Ombi.Controllers { [ApiV1] - [Authorize] + [Admin] [Produces("application/json")] public class RequestRetyController : Controller { From 806cf7c0ffc73182a8099de40ad84b10825eff53 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Tue, 4 Dec 2018 09:45:22 +0000 Subject: [PATCH 11/20] More on the UI !wip --- src/Ombi.Store/Context/OmbiContext.cs | 1 + .../Migrations/20181203213532_RequestQueue.cs | 17 ---- ...> 20181204084915_RequestQueue.Designer.cs} | 24 ++++- .../Migrations/20181204084915_RequestQueue.cs | 35 +++++++ .../Migrations/OmbiContextModelSnapshot.cs | 22 +++++ .../app/interfaces/IFailedRequests.ts | 11 +++ .../ClientApp/app/interfaces/IRequestModel.ts | 2 +- src/Ombi/ClientApp/app/interfaces/index.ts | 1 + src/Ombi/ClientApp/app/services/index.ts | 1 + .../app/services/requestretry.service.ts | 6 +- .../failedrequest.component.html | 25 +++++ .../failedrequests.component.ts | 23 ++--- .../app/settings/jobs/jobs.component.ts | 1 + .../ClientApp/app/settings/settings.module.ts | 3 +- .../Controllers/RequestRetryController.cs | 92 +++++++++++++++++++ src/Ombi/Controllers/RequestRetyController.cs | 45 --------- src/Ombi/Models/FailedRequestViewModel.cs | 17 ++++ 17 files changed, 243 insertions(+), 83 deletions(-) delete mode 100644 src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs rename src/Ombi.Store/Migrations/{20181203213532_RequestQueue.Designer.cs => 20181204084915_RequestQueue.Designer.cs} (98%) create mode 100644 src/Ombi.Store/Migrations/20181204084915_RequestQueue.cs create mode 100644 src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts create mode 100644 src/Ombi/Controllers/RequestRetryController.cs delete mode 100644 src/Ombi/Controllers/RequestRetyController.cs create mode 100644 src/Ombi/Models/FailedRequestViewModel.cs diff --git a/src/Ombi.Store/Context/OmbiContext.cs b/src/Ombi.Store/Context/OmbiContext.cs index 16f26c65a..3d8c05daa 100644 --- a/src/Ombi.Store/Context/OmbiContext.cs +++ b/src/Ombi.Store/Context/OmbiContext.cs @@ -56,6 +56,7 @@ namespace Ombi.Store.Context public DbSet RequestSubscription { get; set; } public DbSet UserNotificationPreferences { get; set; } public DbSet UserQualityProfileses { get; set; } + public DbSet RequestQueue { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { diff --git a/src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs b/src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs deleted file mode 100644 index cd577cc26..000000000 --- a/src/Ombi.Store/Migrations/20181203213532_RequestQueue.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Ombi.Store.Migrations -{ - public partial class RequestQueue : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/src/Ombi.Store/Migrations/20181203213532_RequestQueue.Designer.cs b/src/Ombi.Store/Migrations/20181204084915_RequestQueue.Designer.cs similarity index 98% rename from src/Ombi.Store/Migrations/20181203213532_RequestQueue.Designer.cs rename to src/Ombi.Store/Migrations/20181204084915_RequestQueue.Designer.cs index 5de4398af..468abb2c7 100644 --- a/src/Ombi.Store/Migrations/20181203213532_RequestQueue.Designer.cs +++ b/src/Ombi.Store/Migrations/20181204084915_RequestQueue.Designer.cs @@ -9,7 +9,7 @@ using Ombi.Store.Context; namespace Ombi.Store.Migrations { [DbContext(typeof(OmbiContext))] - [Migration("20181203213532_RequestQueue")] + [Migration("20181204084915_RequestQueue")] partial class RequestQueue { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -510,6 +510,28 @@ namespace Ombi.Store.Migrations b.ToTable("RecentlyAddedLog"); }); + modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Completed"); + + b.Property("Dts"); + + b.Property("Error"); + + b.Property("RequestId"); + + b.Property("RetryCount"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.ToTable("RequestQueue"); + }); + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => { b.Property("Id") diff --git a/src/Ombi.Store/Migrations/20181204084915_RequestQueue.cs b/src/Ombi.Store/Migrations/20181204084915_RequestQueue.cs new file mode 100644 index 000000000..820ce50af --- /dev/null +++ b/src/Ombi.Store/Migrations/20181204084915_RequestQueue.cs @@ -0,0 +1,35 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ombi.Store.Migrations +{ + public partial class RequestQueue : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "RequestQueue", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + RequestId = table.Column(nullable: false), + Type = table.Column(nullable: false), + Dts = table.Column(nullable: false), + Error = table.Column(nullable: true), + Completed = table.Column(nullable: true), + RetryCount = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RequestQueue", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "RequestQueue"); + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs index 672525b41..5a009d5ef 100644 --- a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs @@ -508,6 +508,28 @@ namespace Ombi.Store.Migrations b.ToTable("RecentlyAddedLog"); }); + modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Completed"); + + b.Property("Dts"); + + b.Property("Error"); + + b.Property("RequestId"); + + b.Property("RetryCount"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.ToTable("RequestQueue"); + }); + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => { b.Property("Id") diff --git a/src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts b/src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts new file mode 100644 index 000000000..002904386 --- /dev/null +++ b/src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts @@ -0,0 +1,11 @@ +import { RequestType } from "."; +export interface IFailedRequestsViewModel { + failedId: number; + title: string; + releaseYear: Date; + requestId: number; + requestType: RequestType; + dts: Date; + error: string; + retryCount: number; +} diff --git a/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts b/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts index 310aaa6fd..5a72abf31 100644 --- a/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts +++ b/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts @@ -3,7 +3,7 @@ export enum RequestType { movie = 1, tvShow = 2, - + album = 3, } // NEW WORLD diff --git a/src/Ombi/ClientApp/app/interfaces/index.ts b/src/Ombi/ClientApp/app/interfaces/index.ts index bfc89edc6..e1cf823e8 100644 --- a/src/Ombi/ClientApp/app/interfaces/index.ts +++ b/src/Ombi/ClientApp/app/interfaces/index.ts @@ -17,3 +17,4 @@ export * from "./IRecentlyAdded"; export * from "./ILidarr"; export * from "./ISearchMusicResult"; export * from "./IVote"; +export * from "./IFailedRequests"; diff --git a/src/Ombi/ClientApp/app/services/index.ts b/src/Ombi/ClientApp/app/services/index.ts index c1ccc2585..edffdd625 100644 --- a/src/Ombi/ClientApp/app/services/index.ts +++ b/src/Ombi/ClientApp/app/services/index.ts @@ -15,3 +15,4 @@ export * from "./mobile.service"; export * from "./notificationMessage.service"; export * from "./recentlyAdded.service"; export * from "./vote.service"; +export * from "./requestretry.service"; diff --git a/src/Ombi/ClientApp/app/services/requestretry.service.ts b/src/Ombi/ClientApp/app/services/requestretry.service.ts index 338475609..09e345566 100644 --- a/src/Ombi/ClientApp/app/services/requestretry.service.ts +++ b/src/Ombi/ClientApp/app/services/requestretry.service.ts @@ -4,7 +4,7 @@ import { Injectable } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { Observable } from "rxjs"; -import { IMobileUsersViewModel } from "../interfaces"; +import { IFailedRequestsViewModel } from "../interfaces"; import { ServiceHelpers } from "./service.helpers"; @Injectable() @@ -12,7 +12,7 @@ export class RequestRetryService extends ServiceHelpers { constructor(http: HttpClient, public platformLocation: PlatformLocation) { super(http, "/api/v1/requestretry/", platformLocation); } - public getUserDeviceList(): Observable { - return this.http.get(`${this.url}notification/`, {headers: this.headers}); + public getFailedRequests(): Observable { + return this.http.get(this.url, {headers: this.headers}); } } diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html index 4689eef46..d1e5b13ec 100644 --- a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html @@ -1,3 +1,28 @@  + + + + + + + + + + + + + + + + + + + + + + +
TitleTypeRetry CountError DescriptionRetryDelete
+ {{v.title}} + {{RequestType[v.type] | humanize}}{{v.retryCount}}
diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts index af75a8bf1..214729840 100644 --- a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts @@ -1,25 +1,18 @@ import { Component, OnInit } from "@angular/core"; -import { IAbout } from "../../interfaces/ISettings"; -import { JobService, SettingsService } from "../../services"; +import { IFailedRequestsViewModel, RequestType } from "../../interfaces"; +import { RequestRetryService } from "../../services"; @Component({ - templateUrl: "./about.component.html", + templateUrl: "./failedrequest.component.html", }) -export class AboutComponent implements OnInit { +export class FailedRequestsComponent implements OnInit { - public about: IAbout; - public newUpdate: boolean; + public vm: IFailedRequestsViewModel[]; + public RequestType = RequestType; - constructor(private readonly settingsService: SettingsService, - private readonly jobService: JobService) { } + constructor(private retry: RequestRetryService) { } public ngOnInit() { - this.settingsService.about().subscribe(x => this.about = x); - this.jobService.getCachedUpdate().subscribe(x => { - if (x === true) { - this.newUpdate = true; - } - }); - + this.retry.getFailedRequests().subscribe(x => this.vm = x); } } diff --git a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts index d8ce106ae..853005185 100644 --- a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts +++ b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts @@ -36,6 +36,7 @@ export class JobsComponent implements OnInit { plexRecentlyAddedSync: [x.plexRecentlyAddedSync, Validators.required], lidarrArtistSync: [x.lidarrArtistSync, Validators.required], issuesPurge: [x.issuesPurge, Validators.required], + retryRequests: [x.retryRequests, Validators.required], }); }); } diff --git a/src/Ombi/ClientApp/app/settings/settings.module.ts b/src/Ombi/ClientApp/app/settings/settings.module.ts index e0fd90db9..fb1a10abe 100644 --- a/src/Ombi/ClientApp/app/settings/settings.module.ts +++ b/src/Ombi/ClientApp/app/settings/settings.module.ts @@ -9,7 +9,7 @@ import { AuthGuard } from "../auth/auth.guard"; import { AuthService } from "../auth/auth.service"; import { CouchPotatoService, EmbyService, IssuesService, JobService, LidarrService, MobileService, NotificationMessageService, PlexService, RadarrService, - SonarrService, TesterService, ValidationService, + RequestRetryService, SonarrService, TesterService, ValidationService, } from "../services"; import { PipeModule } from "../pipes/pipe.module"; @@ -152,6 +152,7 @@ const routes: Routes = [ MobileService, NotificationMessageService, LidarrService, + RequestRetryService, ], }) diff --git a/src/Ombi/Controllers/RequestRetryController.cs b/src/Ombi/Controllers/RequestRetryController.cs new file mode 100644 index 000000000..6a53f9732 --- /dev/null +++ b/src/Ombi/Controllers/RequestRetryController.cs @@ -0,0 +1,92 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository; +using System.Collections.Generic; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using Ombi.Attributes; +using Ombi.Models; +using Ombi.Store.Entities; +using Ombi.Store.Repository.Requests; + +namespace Ombi.Controllers +{ + [ApiV1] + [Admin] + [Produces("application/json")] + public class RequestRetryController : Controller + { + public RequestRetryController(IRepository requestQueue, IMovieRequestRepository movieRepo, + ITvRequestRepository tvRepo, IMusicRequestRepository musicRepo) + { + _requestQueueRepository = requestQueue; + _movieRequestRepository = movieRepo; + _tvRequestRepository = tvRepo; + _musicRequestRepository = musicRepo; + } + + private readonly IRepository _requestQueueRepository; + private readonly IMovieRequestRepository _movieRequestRepository; + private readonly ITvRequestRepository _tvRequestRepository; + private readonly IMusicRequestRepository _musicRequestRepository; + + /// + /// Get's all the failed requests that are currently in the queue + /// + /// + [HttpGet] + public async Task> GetFailedRequests() + { + var failed = await _requestQueueRepository.GetAll().Where(x => !x.Completed.HasValue).ToListAsync(); + + var vm = new List(); + foreach (var f in failed) + { + var vmModel = new FailedRequestViewModel + { + RequestId = f.RequestId, + RetryCount = f.RetryCount, + Dts = f.Dts, + Error = f.Error, + FailedId = f.Id, + Type = f.Type + }; + + if (f.Type == RequestType.Movie) + { + var request = await _movieRequestRepository.Find(f.RequestId); + vmModel.Title = request.Title; + vmModel.ReleaseYear = request.ReleaseDate; + } + + if (f.Type == RequestType.Album) + { + var request = await _musicRequestRepository.Find(f.RequestId); + vmModel.Title = request.Title; + vmModel.ReleaseYear = request.ReleaseDate; + } + + if (f.Type == RequestType.TvShow) + { + var request = await _tvRequestRepository.GetChild().Include(x => x.ParentRequest).FirstOrDefaultAsync(x => x.Id == f.RequestId); + vmModel.Title = request.Title; + vmModel.ReleaseYear = request.ParentRequest.ReleaseDate; + } + vm.Add(vmModel); + } + + return vm; + } + + [HttpDelete("{queueId:int}")] + public async Task Delete(int queueId) + { + var queueItem = await _requestQueueRepository.GetAll().FirstOrDefaultAsync(x => x.Id == queueId); + await _requestQueueRepository.Delete(queueItem); + return Ok(); + } + + } +} \ No newline at end of file diff --git a/src/Ombi/Controllers/RequestRetyController.cs b/src/Ombi/Controllers/RequestRetyController.cs deleted file mode 100644 index 69e379838..000000000 --- a/src/Ombi/Controllers/RequestRetyController.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Ombi.Store.Entities.Requests; -using Ombi.Store.Repository; -using System.Collections.Generic; -using System.Linq; -using Microsoft.EntityFrameworkCore; -using Ombi.Attributes; -using Ombi.Store.Entities; - -namespace Ombi.Controllers -{ - [ApiV1] - [Admin] - [Produces("application/json")] - public class RequestRetyController : Controller - { - public RequestRetyController(IRepository requestQueue) - { - _requestQueueRepository = requestQueue; - } - - private readonly IRepository _requestQueueRepository; - - /// - /// Get's all the failed requests that are currently in the queue - /// - /// - [HttpGet] - public async Task> Categories() - { - return await _requestQueueRepository.GetAll().Where(x => !x.Completed.HasValue).ToListAsync(); - } - - [HttpDelete("{queueId:int}")] - public async Task Delete(int queueId) - { - var queueItem = await _requestQueueRepository.GetAll().FirstOrDefaultAsync(x => x.Id == queueId); - await _requestQueueRepository.Delete(queueItem); - return Ok(); - } - - } -} \ No newline at end of file diff --git a/src/Ombi/Models/FailedRequestViewModel.cs b/src/Ombi/Models/FailedRequestViewModel.cs new file mode 100644 index 000000000..bd3f7a858 --- /dev/null +++ b/src/Ombi/Models/FailedRequestViewModel.cs @@ -0,0 +1,17 @@ +using System; +using Ombi.Store.Entities; + +namespace Ombi.Models +{ + public class FailedRequestViewModel + { + public int FailedId { get; set; } + public string Title { get; set; } + public DateTime ReleaseYear { get; set; } + public int RequestId { get; set; } + public RequestType Type { get; set; } + public DateTime Dts { get; set; } + public string Error { get; set; } + public int RetryCount { get; set; } + } +} \ No newline at end of file From 9d2fc81a0c876042c0d6507927361c18dae661dd Mon Sep 17 00:00:00 2001 From: TidusJar Date: Tue, 4 Dec 2018 14:15:38 +0000 Subject: [PATCH 12/20] !wip --- src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts | 2 +- src/Ombi/ClientApp/app/services/requestretry.service.ts | 3 +++ .../app/settings/failedrequests/failedrequest.component.html | 4 +--- .../app/settings/failedrequests/failedrequests.component.ts | 4 ++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts b/src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts index 002904386..51a924db5 100644 --- a/src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts +++ b/src/Ombi/ClientApp/app/interfaces/IFailedRequests.ts @@ -4,7 +4,7 @@ export interface IFailedRequestsViewModel { title: string; releaseYear: Date; requestId: number; - requestType: RequestType; + type: RequestType; dts: Date; error: string; retryCount: number; diff --git a/src/Ombi/ClientApp/app/services/requestretry.service.ts b/src/Ombi/ClientApp/app/services/requestretry.service.ts index 09e345566..9803f73f7 100644 --- a/src/Ombi/ClientApp/app/services/requestretry.service.ts +++ b/src/Ombi/ClientApp/app/services/requestretry.service.ts @@ -15,4 +15,7 @@ export class RequestRetryService extends ServiceHelpers { public getFailedRequests(): Observable { return this.http.get(this.url, {headers: this.headers}); } + public deleteFailedRequest(failedId: number): Observable { + return this.http.delete(`${this.url}/${failedId}`, {headers: this.headers}); + } } diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html index d1e5b13ec..c0cc2ca1e 100644 --- a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html @@ -9,7 +9,6 @@ Type Retry Count Error Description - Retry Delete @@ -21,8 +20,7 @@ {{RequestType[v.type] | humanize}} {{v.retryCount}} - - + diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts index 214729840..65be04a22 100644 --- a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts @@ -15,4 +15,8 @@ export class FailedRequestsComponent implements OnInit { public ngOnInit() { this.retry.getFailedRequests().subscribe(x => this.vm = x); } + + public remove(failedId: number) { + this.retry.deleteFailedRequest(failedId).subscribe(); + } } From d3444059dda456419d5fc7dae32ce807f09aa4af Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 5 Dec 2018 20:48:16 +0000 Subject: [PATCH 13/20] Sorted out the sonarr settings UI !wip --- .../app/settings/sonarr/sonarr.component.html | 50 +++++++++++-------- .../app/settings/sonarr/sonarr.component.ts | 5 +- src/Ombi/ClientApp/styles/Styles.scss | 2 +- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html index 91385c353..f016fd56e 100644 --- a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html +++ b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html @@ -22,34 +22,40 @@
- +
- + - The IP/Hostname is required
- + - The Port is required
- + - The API Key is required
@@ -68,9 +74,10 @@
-
- +
- A Default Quality - Profile is required +
+
+
@@ -94,7 +102,10 @@
- +
- A Default Root Path - is - required
@@ -119,17 +127,17 @@
- +
- + - A Default - Langauage Profile is required
diff --git a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts index ee2438f1b..11845a06e 100644 --- a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts +++ b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts @@ -51,7 +51,7 @@ export class SonarrComponent implements OnInit { addOnly: [x.addOnly], seasonFolders: [x.seasonFolders], v3: [x.v3], - langaugeProfile: [x.languageProfile], + languageProfile: [x.languageProfile], }); if (x.qualityProfile) { @@ -63,6 +63,9 @@ export class SonarrComponent implements OnInit { if(x.languageProfile) { this.getLanguageProfiles(this.form); } + if(x.v3) { + this.form.controls.languageProfile.setValidators([Validators.required]); + } }); this.rootFolders = []; this.qualities = []; diff --git a/src/Ombi/ClientApp/styles/Styles.scss b/src/Ombi/ClientApp/styles/Styles.scss index b41e1c2a7..d98e4cf83 100644 --- a/src/Ombi/ClientApp/styles/Styles.scss +++ b/src/Ombi/ClientApp/styles/Styles.scss @@ -27,4 +27,4 @@ $bg-colour-disabled: #252424; .label { margin: 3px; -} \ No newline at end of file +} From a1c903aa162ed436c33a4290189662eedfe5405f Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 5 Dec 2018 21:06:31 +0000 Subject: [PATCH 14/20] Sorted out some of the settings pages, trying to make it consistent --- .../app/settings/lidarr/lidarr.component.html | 39 +++++--- .../app/settings/radarr/radarr.component.html | 96 +++++++++++-------- .../app/settings/settingsmenu.component.html | 2 +- 3 files changed, 82 insertions(+), 55 deletions(-) diff --git a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html index 50938412f..5e898e719 100644 --- a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html +++ b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html @@ -19,25 +19,28 @@
- + - The IP/Hostname is required
- + - The Port is required +
- + - The API Key is required +
@@ -56,19 +59,22 @@
- +
- - A Default Quality Profile is required
- +
@@ -89,12 +97,14 @@
- A Language profile is required
- +
- A Metadata profile is required
diff --git a/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html b/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html index 909a64226..08a8035c2 100644 --- a/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html +++ b/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html @@ -1,5 +1,4 @@ - - +
Radarr Settings @@ -19,25 +18,34 @@
- + - - The IP/Hostname is required +
- + - - The Port is required +
- - - - The API Key is required + + +
@@ -49,63 +57,73 @@
- +
+
-
- -
-
-
- +
- +
- A Default Quality Profile is required
-
-
- - -
-
- +
- + -
- A Default Root Path is required + + +
+ +
- +
-
- - A Default Minimum Availability is required
- +
+
+
- +
@@ -118,4 +136,4 @@
-
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html index 59ce35c32..f77e77501 100644 --- a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html +++ b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html @@ -54,7 +54,7 @@ Music From 4eeb5d4d355cd89025ba53471e53243ffa1215f1 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 5 Dec 2018 21:24:50 +0000 Subject: [PATCH 15/20] Sorted out the UI !wip --- src/Ombi.Store/Entities/RequestType.cs | 6 +----- src/Ombi/ClientApp/app/interfaces/IRequestModel.ts | 4 ++-- src/Ombi/ClientApp/app/services/requestretry.service.ts | 4 ++-- .../settings/failedrequests/failedrequest.component.html | 2 +- .../settings/failedrequests/failedrequests.component.ts | 9 +++++++-- .../ClientApp/app/settings/settingsmenu.component.html | 1 + src/Ombi/Controllers/RequestRetryController.cs | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Ombi.Store/Entities/RequestType.cs b/src/Ombi.Store/Entities/RequestType.cs index 151453bdd..4d2d20ac4 100644 --- a/src/Ombi.Store/Entities/RequestType.cs +++ b/src/Ombi.Store/Entities/RequestType.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Ombi.Store.Entities +namespace Ombi.Store.Entities { public enum RequestType { diff --git a/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts b/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts index 5a72abf31..b083ca088 100644 --- a/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts +++ b/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts @@ -1,9 +1,9 @@ import { IUser } from "./IUser"; export enum RequestType { + tvShow = 0, movie = 1, - tvShow = 2, - album = 3, + album = 2, } // NEW WORLD diff --git a/src/Ombi/ClientApp/app/services/requestretry.service.ts b/src/Ombi/ClientApp/app/services/requestretry.service.ts index 9803f73f7..e5c9cabe0 100644 --- a/src/Ombi/ClientApp/app/services/requestretry.service.ts +++ b/src/Ombi/ClientApp/app/services/requestretry.service.ts @@ -15,7 +15,7 @@ export class RequestRetryService extends ServiceHelpers { public getFailedRequests(): Observable { return this.http.get(this.url, {headers: this.headers}); } - public deleteFailedRequest(failedId: number): Observable { - return this.http.delete(`${this.url}/${failedId}`, {headers: this.headers}); + public deleteFailedRequest(failedId: number): Observable { + return this.http.delete(`${this.url}/${failedId}`, {headers: this.headers}); } } diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html index c0cc2ca1e..898710199 100644 --- a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequest.component.html @@ -20,7 +20,7 @@ {{RequestType[v.type] | humanize}} {{v.retryCount}} - + diff --git a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts index 65be04a22..a303ac713 100644 --- a/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts +++ b/src/Ombi/ClientApp/app/settings/failedrequests/failedrequests.component.ts @@ -16,7 +16,12 @@ export class FailedRequestsComponent implements OnInit { this.retry.getFailedRequests().subscribe(x => this.vm = x); } - public remove(failedId: number) { - this.retry.deleteFailedRequest(failedId).subscribe(); + public remove(failed: IFailedRequestsViewModel) { + this.retry.deleteFailedRequest(failed.failedId).subscribe(x => { + if(x) { + const index = this.vm.indexOf(failed); + this.vm.splice(index,1); + } + }); } } diff --git a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html index 59ce35c32..eae56bce2 100644 --- a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html +++ b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html @@ -84,6 +84,7 @@