mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Deprecate subscribed state in Search service
This allows for the search service to be cached across all users
This commit is contained in:
parent
614f9b3b21
commit
ff06601978
3 changed files with 3 additions and 58 deletions
|
@ -16,7 +16,6 @@ using Ombi.Store.Repository;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Principal;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ombi.Core.Engine
|
namespace Ombi.Core.Engine
|
||||||
|
@ -216,34 +215,9 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
await RunSearchRules(viewMovie);
|
await RunSearchRules(viewMovie);
|
||||||
|
|
||||||
// This requires the rules to be run first to populate the RequestId property
|
|
||||||
await CheckForSubscription(viewMovie);
|
|
||||||
|
|
||||||
return 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)
|
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieDbSearchResult movie)
|
||||||
{
|
{
|
||||||
|
|
|
@ -393,8 +393,6 @@ namespace Ombi.Core.Engine.V2
|
||||||
|
|
||||||
await RunSearchRules(viewMovie);
|
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);
|
var mapped = Mapper.Map<MovieFullInfoViewModel>(movie);
|
||||||
|
|
||||||
mapped.Available = viewMovie.Available;
|
mapped.Available = viewMovie.Available;
|
||||||
|
@ -406,7 +404,6 @@ namespace Ombi.Core.Engine.V2
|
||||||
mapped.PlexUrl = viewMovie.PlexUrl;
|
mapped.PlexUrl = viewMovie.PlexUrl;
|
||||||
mapped.EmbyUrl = viewMovie.EmbyUrl;
|
mapped.EmbyUrl = viewMovie.EmbyUrl;
|
||||||
mapped.JellyfinUrl = viewMovie.JellyfinUrl;
|
mapped.JellyfinUrl = viewMovie.JellyfinUrl;
|
||||||
mapped.Subscribed = viewMovie.Subscribed;
|
|
||||||
mapped.ShowSubscribe = viewMovie.ShowSubscribe;
|
mapped.ShowSubscribe = viewMovie.ShowSubscribe;
|
||||||
mapped.DigitalReleaseDate = viewMovie.DigitalReleaseDate;
|
mapped.DigitalReleaseDate = viewMovie.DigitalReleaseDate;
|
||||||
mapped.RequestedDate4k = viewMovie.RequestedDate4k;
|
mapped.RequestedDate4k = viewMovie.RequestedDate4k;
|
||||||
|
@ -429,8 +426,6 @@ namespace Ombi.Core.Engine.V2
|
||||||
var mappedMovie = Mapper.Map<SearchMovieViewModel>(movie);
|
var mappedMovie = Mapper.Map<SearchMovieViewModel>(movie);
|
||||||
await RunSearchRules(mappedMovie);
|
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);
|
var mapped = Mapper.Map<MovieCollection>(movie);
|
||||||
|
|
||||||
mapped.Available = movie.Available;
|
mapped.Available = movie.Available;
|
||||||
|
@ -440,7 +435,6 @@ namespace Ombi.Core.Engine.V2
|
||||||
mapped.PlexUrl = movie.PlexUrl;
|
mapped.PlexUrl = movie.PlexUrl;
|
||||||
mapped.EmbyUrl = movie.EmbyUrl;
|
mapped.EmbyUrl = movie.EmbyUrl;
|
||||||
mapped.JellyfinUrl = movie.JellyfinUrl;
|
mapped.JellyfinUrl = movie.JellyfinUrl;
|
||||||
mapped.Subscribed = movie.Subscribed;
|
|
||||||
mapped.ShowSubscribe = movie.ShowSubscribe;
|
mapped.ShowSubscribe = movie.ShowSubscribe;
|
||||||
mapped.ReleaseDate = movie.ReleaseDate;
|
mapped.ReleaseDate = movie.ReleaseDate;
|
||||||
}
|
}
|
||||||
|
@ -470,34 +464,9 @@ namespace Ombi.Core.Engine.V2
|
||||||
|
|
||||||
await RunSearchRules(viewMovie);
|
await RunSearchRules(viewMovie);
|
||||||
|
|
||||||
// This requires the rules to be run first to populate the RequestId property
|
|
||||||
await CheckForSubscription(viewMovie);
|
|
||||||
|
|
||||||
return 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)
|
public async Task<MovieFullInfoViewModel> GetMovieInfoByImdbId(string imdbId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Core.Models.Search
|
namespace Ombi.Core.Models.Search
|
||||||
|
@ -32,6 +33,7 @@ namespace Ombi.Core.Models.Search
|
||||||
public string TheMovieDbId { get; set; }
|
public string TheMovieDbId { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[Obsolete("Use request service instead")]
|
||||||
public bool Subscribed { get; set; }
|
public bool Subscribed { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool ShowSubscribe { get; set; }
|
public bool ShowSubscribe { get; set; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue