mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-13 16:52:56 -07:00
#2932 - Added an api for unavailable requests
This commit is contained in:
parent
cb12160a97
commit
572746351b
4 changed files with 135 additions and 6 deletions
|
@ -209,13 +209,13 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
allRequests =
|
||||
MovieRepository.GetWithUser(shouldHide
|
||||
.UserId);
|
||||
.UserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests =
|
||||
MovieRepository
|
||||
.GetWithUser();
|
||||
.GetWithUser();
|
||||
}
|
||||
|
||||
var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true);
|
||||
|
@ -230,8 +230,8 @@ namespace Ombi.Core.Engine
|
|||
//var secondProp = TypeDescriptor.GetProperties(propType).Find(properties[1], true);
|
||||
}
|
||||
|
||||
allRequests = sortOrder.Equals("asc", StringComparison.InvariantCultureIgnoreCase)
|
||||
? allRequests.OrderBy(x => prop.GetValue(x))
|
||||
allRequests = sortOrder.Equals("asc", StringComparison.InvariantCultureIgnoreCase)
|
||||
? allRequests.OrderBy(x => prop.GetValue(x))
|
||||
: allRequests.OrderByDescending(x => prop.GetValue(x));
|
||||
var total = await allRequests.CountAsync();
|
||||
var requests = await allRequests.Skip(position).Take(count)
|
||||
|
@ -246,8 +246,54 @@ namespace Ombi.Core.Engine
|
|||
Collection = requests,
|
||||
Total = total
|
||||
};
|
||||
|
||||
}
|
||||
public async Task<RequestsViewModel<MovieRequests>> GetUnavailableRequests(int count, int position, string sortProperty, string sortOrder)
|
||||
{
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
IQueryable<MovieRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests =
|
||||
MovieRepository.GetWithUser(shouldHide
|
||||
.UserId).Where(x => !x.Available);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests =
|
||||
MovieRepository
|
||||
.GetWithUser().Where(x => !x.Available);
|
||||
}
|
||||
|
||||
var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true);
|
||||
|
||||
if (sortProperty.Contains('.'))
|
||||
{
|
||||
// This is a navigation property currently not supported
|
||||
prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find("RequestedDate", true);
|
||||
//var properties = sortProperty.Split(new []{'.'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
//var firstProp = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(properties[0], true);
|
||||
//var propType = firstProp.PropertyType;
|
||||
//var secondProp = TypeDescriptor.GetProperties(propType).Find(properties[1], true);
|
||||
}
|
||||
|
||||
allRequests = sortOrder.Equals("asc", StringComparison.InvariantCultureIgnoreCase)
|
||||
? allRequests.OrderBy(x => prop.GetValue(x))
|
||||
: allRequests.OrderByDescending(x => prop.GetValue(x));
|
||||
var total = await allRequests.CountAsync();
|
||||
var requests = await allRequests.Skip(position).Take(count)
|
||||
.ToListAsync();
|
||||
requests.ForEach(async x =>
|
||||
{
|
||||
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
||||
await CheckForSubscription(shouldHide, x);
|
||||
});
|
||||
return new RequestsViewModel<MovieRequests>
|
||||
{
|
||||
Collection = requests,
|
||||
Total = total
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public async Task<RequestEngineResult> UpdateAdvancedOptions(MovieAdvancedOptions options)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue