aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2023-02-20 11:49:46 +0100
committerShadowghost <Ghost_of_Stone@web.de>2023-02-20 11:54:39 +0100
commit5f938de337537ac1e03633c82d2a27a34808d9d0 (patch)
treec909f7c540e5ff13ad9ad4ca2fc38be156996cb6
parentf0251f86cb7d88495de0000d0ebca01fd9b8bbbe (diff)
Build ratingClause with StringBuilder
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs37
1 files changed, 19 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 055131c8e..ecc2a2c91 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -3964,19 +3964,19 @@ namespace Emby.Server.Implementations.Data
whereClauses.Add(clause);
}
- var ratingClause = "(";
+ var ratingClauseBuilder = new StringBuilder("(");
if (query.HasParentalRating ?? false)
{
- ratingClause += "InheritedParentalRatingValue not null";
+ ratingClauseBuilder.Append("InheritedParentalRatingValue not null");
if (query.MinParentalRating.HasValue)
{
- ratingClause += " AND InheritedParentalRatingValue >= @MinParentalRating";
+ ratingClauseBuilder.Append(" AND InheritedParentalRatingValue >= @MinParentalRating");
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
}
if (query.MaxParentalRating.HasValue)
{
- ratingClause += " AND InheritedParentalRatingValue <= @MaxParentalRating";
+ ratingClauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
}
@@ -3985,7 +3985,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@UnratedType";
var index = 0;
string blockedUnratedItems = string.Join(',', query.BlockUnratedItems.Select(_ => paramName + index++));
- ratingClause += "(InheritedParentalRatingValue is null AND UnratedType not in (" + blockedUnratedItems + "))";
+ ratingClauseBuilder.Append("(InheritedParentalRatingValue is null AND UnratedType not in (" + blockedUnratedItems + "))");
if (statement is not null)
{
@@ -3997,12 +3997,12 @@ namespace Emby.Server.Implementations.Data
if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
{
- ratingClause += " OR (";
+ ratingClauseBuilder.Append(" OR (");
}
if (query.MinParentalRating.HasValue)
{
- ratingClause += "InheritedParentalRatingValue >= @MinParentalRating";
+ ratingClauseBuilder.Append("InheritedParentalRatingValue >= @MinParentalRating");
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
}
@@ -4010,49 +4010,50 @@ namespace Emby.Server.Implementations.Data
{
if (query.MinParentalRating.HasValue)
{
- ratingClause += " AND ";
+ ratingClauseBuilder.Append(" AND ");
}
- ratingClause += "InheritedParentalRatingValue <= @MaxParentalRating";
+ ratingClauseBuilder.Append("InheritedParentalRatingValue <= @MaxParentalRating");
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
{
- ratingClause += ")";
+ ratingClauseBuilder.Append(")");
}
if (!(query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue))
{
- ratingClause += " OR InheritedParentalRatingValue not null";
+ ratingClauseBuilder.Append(" OR InheritedParentalRatingValue not null");
}
}
else if (query.MinParentalRating.HasValue)
{
- ratingClause += "InheritedParentalRatingValue is null OR (InheritedParentalRatingValue >= @MinParentalRating";
+ ratingClauseBuilder.Append("InheritedParentalRatingValue is null OR (InheritedParentalRatingValue >= @MinParentalRating");
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
if (query.MaxParentalRating.HasValue)
{
- ratingClause += " AND InheritedParentalRatingValue <= @MaxParentalRating";
+ ratingClauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
- ratingClause += ")";
+ ratingClauseBuilder.Append(")");
}
else if (query.MaxParentalRating.HasValue)
{
- ratingClause += "InheritedParentalRatingValue is null OR InheritedParentalRatingValue <= @MaxParentalRating";
+ ratingClauseBuilder.Append("InheritedParentalRatingValue is null OR InheritedParentalRatingValue <= @MaxParentalRating");
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
else if (!query.HasParentalRating ?? false)
{
- ratingClause += "InheritedParentalRatingValue is null";
+ ratingClauseBuilder.Append("InheritedParentalRatingValue is null");
}
- if (!string.Equals(ratingClause, "(", StringComparison.OrdinalIgnoreCase))
+ var ratingClauseString = ratingClauseBuilder.ToString();
+ if (!string.Equals(ratingClauseString, "(", StringComparison.OrdinalIgnoreCase))
{
- whereClauses.Add(ratingClause + ")");
+ whereClauses.Add(ratingClauseString + ")");
}
if (query.HasOfficialRating.HasValue)