From b9531f0fc0e0f49c33383cdb055edbd40cb29623 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Fri, 8 Apr 2022 09:02:16 +0200 Subject: [PATCH] Better 'denied' request status for TV shows A TV show will be 'Denied' if all its episodes are denied (replaces very recently added 'FullyDenied' property). Individual episodes will show the correct denied status along with the reason. --- src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs | 1 - src/Ombi.Core/Models/Search/SearchTvShowViewModel.cs | 1 - .../Models/Search/V2/SearchFullInfoTvShowViewModel.cs | 1 - src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs | 10 +++++----- src/Ombi.Store/Entities/Requests/SeasonRequests.cs | 2 ++ .../components/card/discover-card.component.ts | 2 +- .../ClientApp/src/app/interfaces/ISearchTvResultV2.ts | 1 - .../components/tv/tv-details.component.html | 4 ++-- 8 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs index 1ebfe0003..344ced813 100644 --- a/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs @@ -310,7 +310,6 @@ namespace Ombi.Core.Engine.V2 item.Available = oldModel.Available; item.Denied = oldModel.Denied; item.DeniedReason = oldModel.DeniedReason; - item.FullyDenied = oldModel.FullyDenied; item.Approved = oldModel.Approved; item.SeasonRequests = oldModel.SeasonRequests; item.RequestId = oldModel.RequestId; diff --git a/src/Ombi.Core/Models/Search/SearchTvShowViewModel.cs b/src/Ombi.Core/Models/Search/SearchTvShowViewModel.cs index 96a98f5d7..1a3f47175 100644 --- a/src/Ombi.Core/Models/Search/SearchTvShowViewModel.cs +++ b/src/Ombi.Core/Models/Search/SearchTvShowViewModel.cs @@ -56,7 +56,6 @@ namespace Ombi.Core.Models.Search public bool FullyAvailable { get; set; } // We only have some episodes public bool PartlyAvailable { get; set; } - public bool FullyDenied { get; set; } public override RequestType Type => RequestType.TvShow; public string BackdropPath { get; set; } diff --git a/src/Ombi.Core/Models/Search/V2/SearchFullInfoTvShowViewModel.cs b/src/Ombi.Core/Models/Search/V2/SearchFullInfoTvShowViewModel.cs index 179178c3e..0902c1fb1 100644 --- a/src/Ombi.Core/Models/Search/V2/SearchFullInfoTvShowViewModel.cs +++ b/src/Ombi.Core/Models/Search/V2/SearchFullInfoTvShowViewModel.cs @@ -48,7 +48,6 @@ namespace Ombi.Core.Models.Search.V2 public bool FullyAvailable { get; set; } // We only have some episodes public bool PartlyAvailable { get; set; } - public bool FullyDenied { get; set; } public override RequestType Type => RequestType.TvShow; } diff --git a/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs b/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs index ffa18e4af..9c98b7708 100644 --- a/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs @@ -61,8 +61,6 @@ namespace Ombi.Core.Rule.Rules.Search request.RequestId = tvRequests.Id; request.Requested = true; request.Approved = tvRequests.ChildRequests.Any(x => x.Approved); - request.Denied = tvRequests.ChildRequests.Any(x => x.Denied ?? false); - request.DeniedReason = tvRequests.ChildRequests.FirstOrDefault(x => x.Denied ?? false)?.DeniedReason; // Let's modify the seasonsrequested to reflect what we have requested... foreach (var season in request.SeasonRequests) @@ -86,7 +84,8 @@ namespace Ombi.Core.Rule.Rules.Search episodeSearching.Requested = true; episodeSearching.Available = ep.Available; episodeSearching.Approved = ep.Season.ChildRequest.Approved; - episodeSearching.Denied = request.Denied; + episodeSearching.Denied = ep.Season.ChildRequest.Denied; + episodeSearching.DeniedReason = ep.Season.ChildRequest.DeniedReason; } } } @@ -103,7 +102,8 @@ namespace Ombi.Core.Rule.Rules.Search if (request.SeasonRequests.Any() && request.SeasonRequests.All(x => x.Episodes.All(e => e.Denied ?? false))) { - request.FullyDenied = true; + request.Denied = true; + request.DeniedReason = tvRequests.ChildRequests.FirstOrDefault(x => x.Denied ?? false)?.DeniedReason; } var hasUnairedRequests = request.SeasonRequests.Any() && request.SeasonRequests.All(x => x.Episodes.Any(e => e.AirDate >= DateTime.UtcNow)); @@ -123,7 +123,7 @@ namespace Ombi.Core.Rule.Rules.Search if (albumRequest != null) // Do we already have a request for this? { obj.Requested = true; - obj.RequestId = albumRequest.Id; + obj.RequestId = albumRequest.Id; obj.Denied = albumRequest.Denied; obj.DeniedReason = albumRequest.DeniedReason; obj.Approved = albumRequest.Approved; diff --git a/src/Ombi.Store/Entities/Requests/SeasonRequests.cs b/src/Ombi.Store/Entities/Requests/SeasonRequests.cs index da224681e..5de8003a1 100644 --- a/src/Ombi.Store/Entities/Requests/SeasonRequests.cs +++ b/src/Ombi.Store/Entities/Requests/SeasonRequests.cs @@ -31,6 +31,8 @@ namespace Ombi.Store.Repository.Requests public bool Requested { get; set; } [NotMapped] public bool? Denied { get; set; } + [NotMapped] + public string DeniedReason { get; set; } public int SeasonId { get; set; } [ForeignKey(nameof(SeasonId))] diff --git a/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts b/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts index a678c780f..559a962b5 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts @@ -213,7 +213,7 @@ export class DiscoverCardComponent implements OnInit { this.result.overview = updated.overview; this.result.approved = updated.approved; this.result.available = updated.fullyAvailable; - this.result.denied = updated.fullyDenied; + this.result.denied = updated.denied; this.fullyLoaded = true; } diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISearchTvResultV2.ts b/src/Ombi/ClientApp/src/app/interfaces/ISearchTvResultV2.ts index ad15306f4..78958a02e 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISearchTvResultV2.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISearchTvResultV2.ts @@ -27,7 +27,6 @@ export interface ISearchTvResultV2 { approved: boolean; denied: boolean; deniedReason: string; - fullyDenied: boolean; requested: boolean; available: boolean; plexUrl: string; diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html index 091f38f29..cb1ec6ffb 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html @@ -65,7 +65,7 @@ (click)="request()"> {{ 'Common.Request' | translate }} - @@ -83,7 +83,7 @@ {{'Common.PartiallyAvailable' | translate }} -