浏览代码

Fixing similar parental rating calculation (#8959)

Brad Beattie 2 年之前
父节点
当前提交
ac9b7142cc
共有 1 个文件被更改,包括 12 次插入3 次删除
  1. 12 3
      Emby.Server.Implementations/Data/SqliteItemRepository.cs

+ 12 - 3
Emby.Server.Implementations/Data/SqliteItemRepository.cs

@@ -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)