Fixing similar parental rating calculation (#8959)

This commit is contained in:
Brad Beattie 2023-01-07 10:31:33 -08:00 committed by GitHub
parent 678bcf9a80
commit ac9b7142cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -2401,13 +2401,17 @@ namespace Emby.Server.Implementations.Data
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.Append('('); builder.Append('(');
if (string.IsNullOrEmpty(item.OfficialRating)) if (item.InheritedParentalRatingValue == 0)
{ {
builder.Append("(OfficialRating is null * 10)"); builder.Append("((InheritedParentalRatingValue=0) * 10)");
} }
else else
{ {
builder.Append("(OfficialRating=@ItemOfficialRating * 10)"); builder.Append(
@"(SELECT CASE WHEN InheritedParentalRatingValue=0
THEN 0
ELSE 10.0 / (1.0 + ABS(InheritedParentalRatingValue - @InheritedParentalRatingValue))
END)");
} }
if (item.ProductionYear.HasValue) if (item.ProductionYear.HasValue)
@ -2521,6 +2525,11 @@ namespace Emby.Server.Implementations.Data
{ {
statement.TryBind("@SimilarItemId", item.Id); statement.TryBind("@SimilarItemId", item.Id);
} }
if (commandText.Contains("@InheritedParentalRatingValue", StringComparison.OrdinalIgnoreCase))
{
statement.TryBind("@InheritedParentalRatingValue", item.InheritedParentalRatingValue);
}
} }
private string GetJoinUserDataText(InternalItemsQuery query) private string GetJoinUserDataText(InternalItemsQuery query)