mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update db querying
This commit is contained in:
parent
52a42229cd
commit
d4870e788a
@ -338,6 +338,18 @@ namespace MediaBrowser.Api.Reports
|
|||||||
query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray();
|
query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Min official rating
|
||||||
|
if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
||||||
|
{
|
||||||
|
query.MinParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Max official rating
|
||||||
|
if (!string.IsNullOrEmpty(request.MaxOfficialRating))
|
||||||
|
{
|
||||||
|
query.MaxParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
|
||||||
|
}
|
||||||
|
|
||||||
if (request.HasQueryLimit == false)
|
if (request.HasQueryLimit == false)
|
||||||
{
|
{
|
||||||
query.StartIndex = null;
|
query.StartIndex = null;
|
||||||
@ -417,67 +429,6 @@ namespace MediaBrowser.Api.Reports
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Min index number
|
|
||||||
if (request.MinIndexNumber.HasValue)
|
|
||||||
{
|
|
||||||
if (!(i.IndexNumber.HasValue && i.IndexNumber.Value >= request.MinIndexNumber.Value))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Min official rating
|
|
||||||
if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
|
||||||
{
|
|
||||||
var level = _localization.GetRatingLevel(request.MinOfficialRating);
|
|
||||||
|
|
||||||
if (level.HasValue)
|
|
||||||
{
|
|
||||||
var rating = i.CustomRating;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
rating = i.OfficialRating;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
var itemLevel = _localization.GetRatingLevel(rating);
|
|
||||||
|
|
||||||
if (!(!itemLevel.HasValue || itemLevel.Value >= level.Value))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Max official rating
|
|
||||||
if (!string.IsNullOrEmpty(request.MaxOfficialRating))
|
|
||||||
{
|
|
||||||
var level = _localization.GetRatingLevel(request.MaxOfficialRating);
|
|
||||||
|
|
||||||
if (level.HasValue)
|
|
||||||
{
|
|
||||||
var rating = i.CustomRating;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
rating = i.OfficialRating;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
var itemLevel = _localization.GetRatingLevel(rating);
|
|
||||||
|
|
||||||
if (!(!itemLevel.HasValue || itemLevel.Value <= level.Value))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,6 +310,18 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray();
|
query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Min official rating
|
||||||
|
if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
||||||
|
{
|
||||||
|
query.MinParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Max official rating
|
||||||
|
if (!string.IsNullOrEmpty(request.MaxOfficialRating))
|
||||||
|
{
|
||||||
|
query.MaxParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
|
||||||
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
@ -384,58 +396,6 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Min official rating
|
|
||||||
if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
|
||||||
{
|
|
||||||
var level = _localization.GetRatingLevel(request.MinOfficialRating);
|
|
||||||
|
|
||||||
if (level.HasValue)
|
|
||||||
{
|
|
||||||
var rating = i.CustomRating;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
rating = i.OfficialRating;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
var itemLevel = _localization.GetRatingLevel(rating);
|
|
||||||
|
|
||||||
if (!(!itemLevel.HasValue || itemLevel.Value >= level.Value))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Max official rating
|
|
||||||
if (!string.IsNullOrEmpty(request.MaxOfficialRating))
|
|
||||||
{
|
|
||||||
var level = _localization.GetRatingLevel(request.MaxOfficialRating);
|
|
||||||
|
|
||||||
if (level.HasValue)
|
|
||||||
{
|
|
||||||
var rating = i.CustomRating;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
rating = i.OfficialRating;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(rating))
|
|
||||||
{
|
|
||||||
var itemLevel = _localization.GetRatingLevel(rating);
|
|
||||||
|
|
||||||
if (!(!itemLevel.HasValue || itemLevel.Value <= level.Value))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1091,12 +1091,6 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.MinIndexNumber.HasValue)
|
|
||||||
{
|
|
||||||
Logger.Debug("Query requires post-filtering due to MinIndexNumber");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query.OfficialRatings.Length > 0)
|
if (query.OfficialRatings.Length > 0)
|
||||||
{
|
{
|
||||||
Logger.Debug("Query requires post-filtering due to OfficialRatings");
|
Logger.Debug("Query requires post-filtering due to OfficialRatings");
|
||||||
|
@ -105,6 +105,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
|
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
|
||||||
public int? ParentIndexNumber { get; set; }
|
public int? ParentIndexNumber { get; set; }
|
||||||
|
public int? MinParentalRating { get; set; }
|
||||||
public int? MaxParentalRating { get; set; }
|
public int? MaxParentalRating { get; set; }
|
||||||
|
|
||||||
public bool? IsCurrentSchema { get; set; }
|
public bool? IsCurrentSchema { get; set; }
|
||||||
|
@ -2062,6 +2062,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
whereClauses.Add(clause);
|
whereClauses.Add(clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (query.MinParentalRating.HasValue)
|
||||||
|
{
|
||||||
|
whereClauses.Add("InheritedParentalRatingValue<=@MinParentalRating");
|
||||||
|
cmd.Parameters.Add(cmd, "@MinParentalRating", DbType.Int32).Value = query.MinParentalRating.Value;
|
||||||
|
}
|
||||||
|
|
||||||
if (query.MaxParentalRating.HasValue)
|
if (query.MaxParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
whereClauses.Add("InheritedParentalRatingValue<=@MaxParentalRating");
|
whereClauses.Add("InheritedParentalRatingValue<=@MaxParentalRating");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user