Merge pull request #2351 from tidusjar/develop

Develop
pull/2357/head v3.0.3421
Jamie 7 years ago committed by GitHub
commit 281d48234c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,21 @@
### **New Features** ### **New Features**
- Added TVRequestsLite. [Jamie]
- Added a smaller and simplier way of getting TV Request info. [Jamie Rees]
### **Fixes**
- Show the popular movies and tv shows by default. [Jamie]
- Fixed #2348. [Jamie]
## v3.0.3407 (2018-06-18)
### **New Features**
- Update appveyor.yml. [Jamie] - Update appveyor.yml. [Jamie]
- Update build.cake. [Jamie] - Update build.cake. [Jamie]

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Core.Models.Requests; using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search; using Ombi.Core.Models.UI;
using Ombi.Store.Entities.Requests; using Ombi.Store.Entities.Requests;
namespace Ombi.Core.Engine.Interfaces namespace Ombi.Core.Engine.Interfaces
@ -10,8 +10,10 @@ namespace Ombi.Core.Engine.Interfaces
{ {
Task RemoveTvRequest(int requestId); Task RemoveTvRequest(int requestId);
Task<TvRequests> GetTvRequest(int requestId);
Task<RequestEngineResult> RequestTvShow(TvRequestViewModel tv); Task<RequestEngineResult> RequestTvShow(TvRequestViewModel tv);
Task<RequestEngineResult> DenyChildRequest(int requestId); Task<RequestEngineResult> DenyChildRequest(int requestId);
Task<RequestsViewModel<TvRequests>> GetRequestsLite(int count, int position, OrderFilterModel type);
Task<IEnumerable<TvRequests>> SearchTvRequest(string search); Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search); Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
Task<TvRequests> UpdateTvRequest(TvRequests request); Task<TvRequests> UpdateTvRequest(TvRequests request);
@ -20,5 +22,6 @@ namespace Ombi.Core.Engine.Interfaces
Task<ChildRequests> UpdateChildRequest(ChildRequests request); Task<ChildRequests> UpdateChildRequest(ChildRequests request);
Task RemoveTvChild(int requestId); Task RemoveTvChild(int requestId);
Task<RequestEngineResult> ApproveChildRequest(int id); Task<RequestEngineResult> ApproveChildRequest(int id);
Task<IEnumerable<TvRequests>> GetRequestsLite();
} }
} }

@ -168,6 +168,35 @@ namespace Ombi.Core.Engine
}; };
} }
public async Task<RequestsViewModel<TvRequests>> GetRequestsLite(int count, int position, OrderFilterModel type)
{
var shouldHide = await HideFromOtherUsers();
List<TvRequests> allRequests;
if (shouldHide.Hide)
{
allRequests = await TvRepository.GetLite(shouldHide.UserId)
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
.Skip(position).Take(count).ToListAsync();
// Filter out children
FilterChildren(allRequests, shouldHide);
}
else
{
allRequests = await TvRepository.GetLite()
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
.Skip(position).Take(count).ToListAsync();
}
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
return new RequestsViewModel<TvRequests>
{
Collection = allRequests
};
}
public async Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position) public async Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position)
{ {
var shouldHide = await HideFromOtherUsers(); var shouldHide = await HideFromOtherUsers();
@ -218,6 +247,45 @@ namespace Ombi.Core.Engine
return allRequests; return allRequests;
} }
public async Task<IEnumerable<TvRequests>> GetRequestsLite()
{
var shouldHide = await HideFromOtherUsers();
List<TvRequests> allRequests;
if (shouldHide.Hide)
{
allRequests = await TvRepository.GetLite(shouldHide.UserId).ToListAsync();
FilterChildren(allRequests, shouldHide);
}
else
{
allRequests = await TvRepository.GetLite().ToListAsync();
}
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
return allRequests;
}
public async Task<TvRequests> GetTvRequest(int requestId)
{
var shouldHide = await HideFromOtherUsers();
TvRequests request;
if (shouldHide.Hide)
{
request = await TvRepository.Get(shouldHide.UserId).Where(x => x.Id == requestId).FirstOrDefaultAsync();
FilterChildren(request, shouldHide);
}
else
{
request = await TvRepository.Get().Where(x => x.Id == requestId).FirstOrDefaultAsync();
}
await CheckForSubscription(shouldHide, request);
return request;
}
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide) private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
{ {
// Filter out children // Filter out children
@ -225,16 +293,27 @@ namespace Ombi.Core.Engine
{ {
for (var j = 0; j < t.ChildRequests.Count; j++) for (var j = 0; j < t.ChildRequests.Count; j++)
{ {
var child = t.ChildRequests[j]; FilterChildren(t, shouldHide);
if (child.RequestedUserId != shouldHide.UserId)
{
t.ChildRequests.RemoveAt(j);
j--;
}
} }
} }
} }
private static void FilterChildren(TvRequests t, HideResult shouldHide)
{
// Filter out children
for (var j = 0; j < t.ChildRequests.Count; j++)
{
var child = t.ChildRequests[j];
if (child.RequestedUserId != shouldHide.UserId)
{
t.ChildRequests.RemoveAt(j);
j--;
}
}
}
public async Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId) public async Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId)
{ {
var shouldHide = await HideFromOtherUsers(); var shouldHide = await HideFromOtherUsers();
@ -470,7 +549,7 @@ namespace Ombi.Core.Engine
{ {
foreach (var tv in x.ChildRequests) foreach (var tv in x.ChildRequests)
{ {
await CheckForSubscription(shouldHide, tv); await CheckForSubscription(shouldHide, tv);
} }
} }

@ -26,7 +26,7 @@ namespace Ombi.Schedule.Tests
_tv = new Mock<ITvRequestRepository>(); _tv = new Mock<ITvRequestRepository>();
_movie = new Mock<IMovieRequestRepository>(); _movie = new Mock<IMovieRequestRepository>();
_notify = new Mock<INotificationService>(); _notify = new Mock<INotificationService>();
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, new Mock<IBackgroundJobClient>().Object); Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, new Mock<IBackgroundJobClient>().Object, null);
} }

@ -104,13 +104,13 @@ namespace Ombi.Schedule.Jobs.Plex
BackgroundJob.Enqueue(() => EpisodeSync.Start()); BackgroundJob.Enqueue(() => EpisodeSync.Start());
} }
if (processedContent.HasProcessedContent && recentlyAddedSearch) if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
{ {
// Just check what we send it // Just check what we send it
BackgroundJob.Enqueue(() => Metadata.ProcessPlexServerContent(processedContent.Content)); BackgroundJob.Enqueue(() => Metadata.ProcessPlexServerContent(processedContent.Content));
} }
if (processedContent.HasProcessedEpisodes && recentlyAddedSearch) if ((processedContent?.HasProcessedEpisodes ?? false) && recentlyAddedSearch)
{ {
BackgroundJob.Enqueue(() => Checker.Start()); BackgroundJob.Enqueue(() => Checker.Start());
} }
@ -165,7 +165,7 @@ namespace Ombi.Schedule.Jobs.Plex
{ {
Logger.LogInformation("Found some episodes, this must be a recently added sync"); Logger.LogInformation("Found some episodes, this must be a recently added sync");
var count = 0; var count = 0;
foreach (var epInfo in content.Metadata) foreach (var epInfo in content.Metadata ?? new Metadata[]{})
{ {
count++; count++;
var grandParentKey = epInfo.grandparentRatingKey; var grandParentKey = epInfo.grandparentRatingKey;
@ -199,9 +199,11 @@ namespace Ombi.Schedule.Jobs.Plex
// Save just to make sure we don't leave anything hanging // Save just to make sure we don't leave anything hanging
await Repo.SaveChangesAsync(); await Repo.SaveChangesAsync();
if (content.Metadata != null)
var episodesAdded = await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps); {
episodesProcessed.AddRange(episodesAdded.Select(x => x.Id)); var episodesAdded = await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps);
episodesProcessed.AddRange(episodesAdded.Select(x => x.Id));
}
} }
if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase)) if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase))
{ {
@ -350,7 +352,7 @@ namespace Ombi.Schedule.Jobs.Plex
} }
// Do we already have this item? // Do we already have this item?
// Let's try and match // Let's try and match
var existingContent = await Repo.GetFirstContentByCustom(x => x.Title == show.title var existingContent = await Repo.GetFirstContentByCustom(x => x.Title == show.title
&& x.ReleaseYear == show.year.ToString() && x.ReleaseYear == show.year.ToString()
&& x.Type == PlexMediaTypeEntity.Show); && x.Type == PlexMediaTypeEntity.Show);
@ -371,6 +373,10 @@ namespace Ombi.Schedule.Jobs.Plex
await Repo.Delete(existingKey); await Repo.Delete(existingKey);
existingKey = null; existingKey = null;
} }
else if(existingContent == null)
{
existingContent = await Repo.GetFirstContentByCustom(x => x.Key == show.ratingKey);
}
} }
if (existingContent != null) if (existingContent != null)

@ -14,7 +14,9 @@ namespace Ombi.Store.Repository.Requests
Task Delete(TvRequests request); Task Delete(TvRequests request);
Task DeleteChild(ChildRequests request); Task DeleteChild(ChildRequests request);
IQueryable<TvRequests> Get(); IQueryable<TvRequests> Get();
IQueryable<TvRequests> GetLite();
IQueryable<TvRequests> Get(string userId); IQueryable<TvRequests> Get(string userId);
IQueryable<TvRequests> GetLite(string userId);
Task<TvRequests> GetRequestAsync(int tvDbId); Task<TvRequests> GetRequestAsync(int tvDbId);
TvRequests GetRequest(int tvDbId); TvRequests GetRequest(int tvDbId);
Task Update(TvRequests request); Task Update(TvRequests request);

@ -60,6 +60,24 @@ namespace Ombi.Store.Repository.Requests
.Where(x => x.ChildRequests.Any(a => a.RequestedUserId == userId)) .Where(x => x.ChildRequests.Any(a => a.RequestedUserId == userId))
.AsQueryable(); .AsQueryable();
} }
public IQueryable<TvRequests> GetLite(string userId)
{
return Db.TvRequests
.Include(x => x.ChildRequests)
.ThenInclude(x => x.RequestedUser)
.Where(x => x.ChildRequests.Any(a => a.RequestedUserId == userId))
.AsQueryable();
}
public IQueryable<TvRequests> GetLite()
{
return Db.TvRequests
.Include(x => x.ChildRequests)
.ThenInclude(x => x.RequestedUser)
.AsQueryable();
}
public IQueryable<ChildRequests> GetChild() public IQueryable<ChildRequests> GetChild()
{ {
return Db.ChildRequests return Db.ChildRequests

@ -70,6 +70,7 @@ export class MovieSearchComponent implements OnInit {
result: false, result: false,
errorMessage: "", errorMessage: "",
}; };
this.popularMovies();
} }
public search(text: any) { public search(text: any) {

@ -93,6 +93,7 @@ export class TvSearchComponent implements OnInit {
result: false, result: false,
errorMessage:"", errorMessage:"",
}; };
this.popularShows();
} }
public search(text: any) { public search(text: any) {

@ -189,8 +189,28 @@ namespace Ombi.Controllers
return await TvRequestEngine.GetRequests(count, position, new OrderFilterModel return await TvRequestEngine.GetRequests(count, position, new OrderFilterModel
{ {
OrderType = (OrderType)orderType, OrderType = (OrderType)orderType,
AvailabilityFilter = (FilterType) availabilityType, AvailabilityFilter = (FilterType)availabilityType,
StatusFilter = (FilterType) statusType, StatusFilter = (FilterType)statusType,
});
}
/// <summary>
/// Gets the tv requests lite.
/// </summary>
/// <param name="count">The count of items you want to return.</param>
/// <param name="position">The position.</param>
/// <param name="orderType"></param>
/// <param name="statusType"></param>
/// <param name="availabilityType"></param>
/// <returns></returns>
[HttpGet("tvlite/{count:int}/{position:int}/{orderType:int}/{statusFilterType:int}/{availabilityFilterType:int}")]
public async Task<RequestsViewModel<TvRequests>> GetTvRequestsLite(int count, int position, int orderType, int statusType, int availabilityType)
{
return await TvRequestEngine.GetRequestsLite(count, position, new OrderFilterModel
{
OrderType = (OrderType)orderType,
AvailabilityFilter = (FilterType)availabilityType,
StatusFilter = (FilterType)statusType,
}); });
} }
@ -204,6 +224,27 @@ namespace Ombi.Controllers
return await TvRequestEngine.GetRequests(); return await TvRequestEngine.GetRequests();
} }
/// <summary>
/// Gets the tv requests without the whole object graph (Does not include seasons/episodes).
/// </summary>
/// <returns></returns>
[HttpGet("tvlite")]
public async Task<IEnumerable<TvRequests>> GetTvRequestsLite()
{
return await TvRequestEngine.GetRequestsLite();
}
/// <summary>
/// Returns the full request object for the specified requestId
/// </summary>
/// <param name="requestId"></param>
/// <returns></returns>
[HttpGet("tv/{requestId:int}")]
public async Task<TvRequests> GetTvRequest(int requestId)
{
return await TvRequestEngine.GetTvRequest(requestId);
}
/// <summary> /// <summary>
/// Requests a tv show/episode/season. /// Requests a tv show/episode/season.
/// </summary> /// </summary>

@ -2,19 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper; using AutoMapper;
using Hangfire; using Hangfire;
using Hangfire.RecurringJobExtensions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Extensions.PlatformAbstractions;
using NCrontab; using NCrontab;
using Ombi.Api.Emby; using Ombi.Api.Emby;

@ -10,7 +10,6 @@
}, },
"ApplicationSettings": { "ApplicationSettings": {
"Verison": "{{VERSIONNUMBER}}", "Verison": "{{VERSIONNUMBER}}",
"OmbiService": "https://ombiservice.azurewebsites.net/",
"Branch": "{{BRANCH}}", "Branch": "{{BRANCH}}",
"FriendlyVersion": "v3.0.0" "FriendlyVersion": "v3.0.0"
}, },

Loading…
Cancel
Save