mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
perf: stop populating obsolete subscribe fields (#4625)
This commit is contained in:
parent
4d1ba5e82a
commit
9a73463766
3 changed files with 1 additions and 59 deletions
|
@ -16,7 +16,6 @@ using Ombi.Store.Repository;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
|
@ -216,34 +215,9 @@ namespace Ombi.Core.Engine
|
|||
|
||||
await RunSearchRules(viewMovie);
|
||||
|
||||
// This requires the rules to be run first to populate the RequestId property
|
||||
await CheckForSubscription(viewMovie);
|
||||
|
||||
return viewMovie;
|
||||
}
|
||||
|
||||
private async Task CheckForSubscription(SearchMovieViewModel viewModel)
|
||||
{
|
||||
// Check if this user requested it
|
||||
var user = await GetUser();
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var request = await RequestService.MovieRequestService.GetAll()
|
||||
.AnyAsync(x => x.RequestedUserId.Equals(user.Id) && x.TheMovieDbId == viewModel.Id);
|
||||
if (request || viewModel.Available)
|
||||
{
|
||||
viewModel.ShowSubscribe = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewModel.ShowSubscribe = true;
|
||||
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => s.UserId == user.Id
|
||||
&& s.RequestId == viewModel.RequestId && s.RequestType == RequestType.Movie);
|
||||
viewModel.Subscribed = sub != null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieDbSearchResult movie)
|
||||
{
|
||||
|
|
|
@ -402,8 +402,6 @@ namespace Ombi.Core.Engine.V2
|
|||
|
||||
await RunSearchRules(viewMovie);
|
||||
|
||||
// This requires the rules to be run first to populate the RequestId property
|
||||
await CheckForSubscription(viewMovie);
|
||||
var mapped = Mapper.Map<MovieFullInfoViewModel>(movie);
|
||||
|
||||
mapped.Available = viewMovie.Available;
|
||||
|
@ -415,8 +413,6 @@ namespace Ombi.Core.Engine.V2
|
|||
mapped.PlexUrl = viewMovie.PlexUrl;
|
||||
mapped.EmbyUrl = viewMovie.EmbyUrl;
|
||||
mapped.JellyfinUrl = viewMovie.JellyfinUrl;
|
||||
mapped.Subscribed = viewMovie.Subscribed;
|
||||
mapped.ShowSubscribe = viewMovie.ShowSubscribe;
|
||||
mapped.DigitalReleaseDate = viewMovie.DigitalReleaseDate;
|
||||
mapped.RequestedDate4k = viewMovie.RequestedDate4k;
|
||||
mapped.Approved4K = viewMovie.Approved4K;
|
||||
|
@ -438,8 +434,6 @@ namespace Ombi.Core.Engine.V2
|
|||
var mappedMovie = Mapper.Map<SearchMovieViewModel>(movie);
|
||||
await RunSearchRules(mappedMovie);
|
||||
|
||||
// This requires the rules to be run first to populate the RequestId property
|
||||
await CheckForSubscription(mappedMovie);
|
||||
var mapped = Mapper.Map<MovieCollection>(movie);
|
||||
|
||||
mapped.Available = movie.Available;
|
||||
|
@ -449,8 +443,6 @@ namespace Ombi.Core.Engine.V2
|
|||
mapped.PlexUrl = movie.PlexUrl;
|
||||
mapped.EmbyUrl = movie.EmbyUrl;
|
||||
mapped.JellyfinUrl = movie.JellyfinUrl;
|
||||
mapped.Subscribed = movie.Subscribed;
|
||||
mapped.ShowSubscribe = movie.ShowSubscribe;
|
||||
mapped.ReleaseDate = movie.ReleaseDate;
|
||||
}
|
||||
return viewMovie;
|
||||
|
@ -479,34 +471,9 @@ namespace Ombi.Core.Engine.V2
|
|||
|
||||
await RunSearchRules(viewMovie);
|
||||
|
||||
// This requires the rules to be run first to populate the RequestId property
|
||||
await CheckForSubscription(viewMovie);
|
||||
|
||||
return viewMovie;
|
||||
}
|
||||
|
||||
private async Task CheckForSubscription(SearchViewModel viewModel)
|
||||
{
|
||||
// Check if this user requested it
|
||||
var user = await GetUser();
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var request = await RequestService.MovieRequestService.GetAll()
|
||||
.AnyAsync(x => x.RequestedUserId.Equals(user.Id) && x.TheMovieDbId == viewModel.Id);
|
||||
if (request)
|
||||
{
|
||||
viewModel.ShowSubscribe = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewModel.ShowSubscribe = true;
|
||||
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => s.UserId == user.Id
|
||||
&& s.RequestId == viewModel.RequestId && s.RequestType == RequestType.Movie);
|
||||
viewModel.Subscribed = sub != null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MovieFullInfoViewModel> GetMovieInfoByImdbId(string imdbId, CancellationToken cancellationToken)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace Ombi.Core.Models.Search
|
|||
[Obsolete("Use request service instead")]
|
||||
public bool Subscribed { get; set; }
|
||||
[NotMapped]
|
||||
[Obsolete("Use request service instead")]
|
||||
public bool ShowSubscribe { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue