aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/SqliteItemRepository.cs
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2023-01-19 10:09:32 +0100
committerShadowghost <Ghost_of_Stone@web.de>2023-01-19 10:09:32 +0100
commit656a0bff6fd48ba66cfe8fc7b470380c38afbac2 (patch)
treea89f0545050bf6672936c6e7ea3e2b0e5c5561f2 /Emby.Server.Implementations/Data/SqliteItemRepository.cs
parentef085483b2ef54195e16f282330a3c204e3227b6 (diff)
parentd57dcf22452db4990aa2cdece3eb798ba98b8330 (diff)
Merge remote-tracking branch 'upstream/master' into network-rewrite
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteItemRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs53
1 files changed, 15 insertions, 38 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 9bdc4e5c8..bc703fe90 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -359,8 +359,6 @@ namespace Emby.Server.Implementations.Data
string[] queries =
{
- "PRAGMA locking_mode=EXCLUSIVE",
-
"create table if not exists TypedBaseItems (guid GUID primary key NOT NULL, type TEXT NOT NULL, data BLOB NULL, ParentId GUID NULL, Path TEXT NULL)",
"create table if not exists AncestorIds (ItemId GUID NOT NULL, AncestorId GUID NOT NULL, AncestorIdText TEXT NOT NULL, PRIMARY KEY (ItemId, AncestorId))",
@@ -385,39 +383,6 @@ namespace Emby.Server.Implementations.Data
string[] postQueries =
{
- // obsolete
- "drop index if exists idx_TypedBaseItems",
- "drop index if exists idx_mediastreams",
- "drop index if exists idx_mediastreams1",
- "drop index if exists idx_" + ChaptersTableName,
- "drop index if exists idx_UserDataKeys1",
- "drop index if exists idx_UserDataKeys2",
- "drop index if exists idx_TypeTopParentId3",
- "drop index if exists idx_TypeTopParentId2",
- "drop index if exists idx_TypeTopParentId4",
- "drop index if exists idx_Type",
- "drop index if exists idx_TypeTopParentId",
- "drop index if exists idx_GuidType",
- "drop index if exists idx_TopParentId",
- "drop index if exists idx_TypeTopParentId6",
- "drop index if exists idx_ItemValues2",
- "drop index if exists Idx_ProviderIds",
- "drop index if exists idx_ItemValues3",
- "drop index if exists idx_ItemValues4",
- "drop index if exists idx_ItemValues5",
- "drop index if exists idx_UserDataKeys3",
- "drop table if exists UserDataKeys",
- "drop table if exists ProviderIds",
- "drop index if exists Idx_ProviderIds1",
- "drop table if exists Images",
- "drop index if exists idx_Images",
- "drop index if exists idx_TypeSeriesPresentationUniqueKey",
- "drop index if exists idx_SeriesPresentationUniqueKey",
- "drop index if exists idx_TypeSeriesPresentationUniqueKey2",
- "drop index if exists idx_AncestorIds3",
- "drop index if exists idx_AncestorIds4",
- "drop index if exists idx_AncestorIds2",
-
"create index if not exists idx_PathTypedBaseItems on TypedBaseItems(Path)",
"create index if not exists idx_ParentIdTypedBaseItems on TypedBaseItems(ParentId)",
@@ -458,6 +423,9 @@ namespace Emby.Server.Implementations.Data
// Used to update inherited tags
"create index if not exists idx_ItemValues8 on ItemValues(Type, ItemId, Value)",
+
+ "CREATE INDEX IF NOT EXISTS idx_TypedBaseItemsUserDataKeyType ON TypedBaseItems(UserDataKey, Type)",
+ "CREATE INDEX IF NOT EXISTS idx_PeopleNameListOrder ON People(Name, ListOrder)"
};
using (var connection = GetConnection())
@@ -2401,13 +2369,17 @@ namespace Emby.Server.Implementations.Data
var builder = new StringBuilder();
builder.Append('(');
- if (string.IsNullOrEmpty(item.OfficialRating))
+ if (item.InheritedParentalRatingValue == 0)
{
- builder.Append("(OfficialRating is null * 10)");
+ builder.Append("((InheritedParentalRatingValue=0) * 10)");
}
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)
@@ -2521,6 +2493,11 @@ namespace Emby.Server.Implementations.Data
{
statement.TryBind("@SimilarItemId", item.Id);
}
+
+ if (commandText.Contains("@InheritedParentalRatingValue", StringComparison.OrdinalIgnoreCase))
+ {
+ statement.TryBind("@InheritedParentalRatingValue", item.InheritedParentalRatingValue);
+ }
}
private string GetJoinUserDataText(InternalItemsQuery query)