Fixed logo on reset password pages

fixed the run importer button on the user management settings

Added root and qulaity profile selection for movies #1517
Added the Sonarr Cacher #1513

Refactored what we do to tv searches to use the rules engine
Cache a few more things to speed some searches up
This commit is contained in:
Jamie.Rees 2017-10-02 13:06:16 +01:00
parent aad5c2a4bc
commit 9ae5ad0ecd
43 changed files with 1313 additions and 281 deletions

View file

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Ombi.Core.Models.Search;
using Ombi.Core.Rule.Interfaces;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
@ -21,28 +22,75 @@ namespace Ombi.Core.Rule.Rules.Search
public Task<RuleResult> Execute(SearchViewModel obj)
{
var movieRequests = Movie.GetRequest(obj.Id);
if (movieRequests != null) // Do we already have a request for this?
if (obj.Type == RequestType.Movie)
{
var movieRequests = Movie.GetRequest(obj.Id);
if (movieRequests != null) // Do we already have a request for this?
{
obj.Requested = true;
obj.Approved = movieRequests.Approved;
obj.Available = movieRequests.Available;
return Task.FromResult(Success());
}
return Task.FromResult(Success());
}
else
{
//var tvRequests = Tv.GetRequest(obj.Id);
//if (tvRequests != null) // Do we already have a request for this?
//{
// obj.Requested = true;
// obj.Approved = tvRequests.ChildRequests.Any(x => x.Approved);
// obj.Available = tvRequests.ChildRequests.Any(x => x.Available);
// return Task.FromResult(Success());
//}
var request = (SearchTvShowViewModel) obj;
var tvRequests = Tv.GetRequest(obj.Id);
if (tvRequests != null) // Do we already have a request for this?
{
request.Requested = true;
request.Approved = tvRequests.ChildRequests.Any(x => x.Approved);
// Let's modify the seasonsrequested to reflect what we have requested...
foreach (var season in request.SeasonRequests)
{
foreach (var existingRequestChildRequest in tvRequests.ChildRequests)
{
// Find the existing request season
var existingSeason =
existingRequestChildRequest.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == season.SeasonNumber);
if (existingSeason == null) continue;
foreach (var ep in existingSeason.Episodes)
{
// Find the episode from what we are searching
var episodeSearching = season.Episodes.FirstOrDefault(x => x.EpisodeNumber == ep.EpisodeNumber);
if (episodeSearching == null)
{
continue;
}
episodeSearching.Requested = true;
episodeSearching.Available = ep.Available;
episodeSearching.Approved = ep.Season.ChildRequest.Approved;
}
}
}
}
if (request.SeasonRequests.Any() && request.SeasonRequests.All(x => x.Episodes.All(e => e.Approved)))
{
request.FullyAvailable = true;
}
obj.Requested = true;
obj.Approved = movieRequests.Approved;
obj.Available = movieRequests.Available;
return Task.FromResult(Success());
}
var tvRequests = Tv.GetRequest(obj.Id);
if (tvRequests != null) // Do we already have a request for this?
{
obj.Requested = true;
obj.Approved = tvRequests.ChildRequests.Any(x => x.Approved);
obj.Available = tvRequests.ChildRequests.Any(x => x.Available);
return Task.FromResult(Success());
}
return Task.FromResult(Success());
}
}
}