feat(discover): Default trending source to new logic

pull/4624/head
sephrat 3 years ago
parent 70a6a8f953
commit 4f12939e22

@ -200,16 +200,16 @@ namespace Ombi.Core.Engine.V2
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies(int currentPosition, int amountToLoad) public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies(int currentPosition, int amountToLoad)
{ {
var langCode = await DefaultLanguageCode(null); var langCode = await DefaultLanguageCode(null);
var isNewTrendingSourceEnabled = await _feature.FeatureEnabled(FeatureNames.NewTrendingSource); var isOldTrendingSourceEnabled = await _feature.FeatureEnabled(FeatureNames.OldTrendingSource);
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems); var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
var results = new List<MovieDbSearchResult>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var search = () => (isNewTrendingSourceEnabled) ? var search = () => (isOldTrendingSourceEnabled) ?
MovieApi.TrendingMovies(langCode, pagesToLoad.Page) MovieApi.NowPlaying(langCode, pagesToLoad.Page)
: MovieApi.NowPlaying(langCode, pagesToLoad.Page); : MovieApi.TrendingMovies(langCode, pagesToLoad.Page);
var apiResult = await Cache.GetOrAddAsync(nameof(NowPlayingMovies) + pagesToLoad.Page + langCode, var apiResult = await Cache.GetOrAddAsync(nameof(NowPlayingMovies) + pagesToLoad.Page + langCode,
search, DateTimeOffset.Now.AddHours(12)); search, DateTimeOffset.Now.AddHours(12));

@ -138,15 +138,15 @@ namespace Ombi.Core.Engine.V2
public async Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentlyLoaded, int amountToLoad) public async Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentlyLoaded, int amountToLoad)
{ {
var langCode = await DefaultLanguageCode(null); var langCode = await DefaultLanguageCode(null);
var isNewTrendingSourceEnabled = await _feature.FeatureEnabled(FeatureNames.NewTrendingSource); var isOldTrendingSourceEnabled = await _feature.FeatureEnabled(FeatureNames.OldTrendingSource);
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit); var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
var results = new List<MovieDbSearchResult>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var search = ( async () => (isNewTrendingSourceEnabled) ? var search = ( async () => (isOldTrendingSourceEnabled) ?
await _movieApi.TrendingTv(langCode, pagesToLoad.Page) await _movieApi.TopRatedTv(langCode, pagesToLoad.Page)
: await _movieApi.TopRatedTv(langCode, pagesToLoad.Page)); : await _movieApi.TrendingTv(langCode, pagesToLoad.Page));
var apiResult = await Cache.GetOrAddAsync(nameof(Trending) + langCode + pagesToLoad.Page, var apiResult = await Cache.GetOrAddAsync(nameof(Trending) + langCode + pagesToLoad.Page,
search, DateTimeOffset.Now.AddHours(12)); search, DateTimeOffset.Now.AddHours(12));
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take)); results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));

@ -20,6 +20,6 @@ namespace Ombi.Settings.Settings.Models
public static class FeatureNames public static class FeatureNames
{ {
public const string Movie4KRequests = nameof(Movie4KRequests); public const string Movie4KRequests = nameof(Movie4KRequests);
public const string NewTrendingSource = nameof(NewTrendingSource); public const string OldTrendingSource = nameof(OldTrendingSource);
} }
} }

Loading…
Cancel
Save