support querying more fields

This commit is contained in:
Luke Pulverenti 2016-06-01 02:01:43 -04:00
parent e1f562e16f
commit 669af87014
2 changed files with 22 additions and 16 deletions

View file

@ -793,11 +793,6 @@ namespace MediaBrowser.Controller.Entities
Logger.Debug("Query requires post-filtering due to ItemSortBy.Metascore");
return true;
}
if (query.SortBy.Contains(ItemSortBy.OfficialRating, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.OfficialRating");
return true;
}
if (query.SortBy.Contains(ItemSortBy.Players, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.Players");
@ -813,11 +808,6 @@ namespace MediaBrowser.Controller.Entities
Logger.Debug("Query requires post-filtering due to ItemSortBy.SeriesSortName");
return true;
}
if (query.SortBy.Contains(ItemSortBy.Studio, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.Studio");
return true;
}
if (query.SortBy.Contains(ItemSortBy.VideoBitRate, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.VideoBitRate");
@ -962,12 +952,6 @@ namespace MediaBrowser.Controller.Entities
return true;
}
if (query.OfficialRatings.Length > 0)
{
Logger.Debug("Query requires post-filtering due to OfficialRatings");
return true;
}
if (query.IsMissing.HasValue)
{
Logger.Debug("Query requires post-filtering due to IsMissing");

View file

@ -1913,6 +1913,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
return new Tuple<string, bool>("(select value from itemvalues where ItemId=Guid and Type=1 LIMIT 1)", false);
}
if (string.Equals(name, ItemSortBy.OfficialRating, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("ParentalRatingValue", false);
}
if (string.Equals(name, ItemSortBy.Studio, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("(select value from itemvalues where ItemId=Guid and Type=3 LIMIT 1)", false);
}
return new Tuple<string, bool>(name, false);
}
@ -2573,6 +2581,20 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add(clause);
}
if (query.OfficialRatings.Length > 0)
{
var clauses = new List<string>();
var index = 0;
foreach (var item in query.OfficialRatings)
{
clauses.Add("OfficialRating=@OfficialRating" + index);
cmd.Parameters.Add(cmd, "@OfficialRating" + index, DbType.String).Value = item;
index++;
}
var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
whereClauses.Add(clause);
}
if (query.MinParentalRating.HasValue)
{
whereClauses.Add("InheritedParentalRatingValue<=@MinParentalRating");