add userdata index
This commit is contained in:
parent
f58a919488
commit
e69f7b757f
|
@ -1276,26 +1276,22 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
{
|
||||
dto.Artists = hasArtist.Artists;
|
||||
|
||||
dto.ArtistItems = hasArtist
|
||||
.Artists
|
||||
var artistItems = _libraryManager.GetArtists(new InternalItemsQuery
|
||||
{
|
||||
EnableTotalRecordCount = false,
|
||||
ItemIds = new[] { item.Id.ToString("N") }
|
||||
});
|
||||
|
||||
dto.ArtistItems = artistItems.Items
|
||||
.Select(i =>
|
||||
{
|
||||
try
|
||||
var artist = i.Item1;
|
||||
return new NameIdPair
|
||||
{
|
||||
var artist = _libraryManager.GetArtist(i);
|
||||
return new NameIdPair
|
||||
{
|
||||
Name = artist.Name,
|
||||
Id = artist.Id.ToString("N")
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting artist", ex);
|
||||
return null;
|
||||
}
|
||||
Name = artist.Name,
|
||||
Id = artist.Id.ToString("N")
|
||||
};
|
||||
})
|
||||
.Where(i => i != null)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -1304,26 +1300,22 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
{
|
||||
dto.AlbumArtist = hasAlbumArtist.AlbumArtists.FirstOrDefault();
|
||||
|
||||
dto.AlbumArtists = hasAlbumArtist
|
||||
.AlbumArtists
|
||||
var artistItems = _libraryManager.GetAlbumArtists(new InternalItemsQuery
|
||||
{
|
||||
EnableTotalRecordCount = false,
|
||||
ItemIds = new[] { item.Id.ToString("N") }
|
||||
});
|
||||
|
||||
dto.ArtistItems = artistItems.Items
|
||||
.Select(i =>
|
||||
{
|
||||
try
|
||||
var artist = i.Item1;
|
||||
return new NameIdPair
|
||||
{
|
||||
var artist = _libraryManager.GetArtist(i);
|
||||
return new NameIdPair
|
||||
{
|
||||
Name = artist.Name,
|
||||
Id = artist.Id.ToString("N")
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting album artist", ex);
|
||||
return null;
|
||||
}
|
||||
Name = artist.Name,
|
||||
Id = artist.Id.ToString("N")
|
||||
};
|
||||
})
|
||||
.Where(i => i != null)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -1604,7 +1596,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
{
|
||||
IsFolder = false,
|
||||
Recursive = true,
|
||||
ExcludeLocationTypes = new[] {LocationType.Virtual},
|
||||
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
||||
User = user
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
|
|
@ -944,9 +944,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
private T CreateItemByName<T>(string path, string name)
|
||||
where T : BaseItem, new()
|
||||
{
|
||||
var isArtist = typeof(T) == typeof(MusicArtist);
|
||||
|
||||
if (isArtist)
|
||||
if (typeof(T) == typeof(MusicArtist))
|
||||
{
|
||||
var existing = GetItemList(new InternalItemsQuery
|
||||
{
|
||||
|
@ -1277,11 +1275,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
return item;
|
||||
}
|
||||
|
||||
private bool EnableCaching
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetItemList(InternalItemsQuery query)
|
||||
{
|
||||
if (query.User != null)
|
||||
|
@ -1289,14 +1282,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
if (!EnableCaching)
|
||||
{
|
||||
return ItemRepository.GetItemList(query);
|
||||
}
|
||||
|
||||
var result = ItemRepository.GetItemIdsList(query);
|
||||
|
||||
return result.Select(GetItemById).Where(i => i != null);
|
||||
return ItemRepository.GetItemList(query);
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
|
||||
|
@ -1426,12 +1412,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
|
||||
SetTopParentIdsOrAncestors(query, parents);
|
||||
|
||||
if (!EnableCaching)
|
||||
{
|
||||
return ItemRepository.GetItemList(query);
|
||||
}
|
||||
|
||||
return GetItemIds(query).Select(GetItemById).Where(i => i != null);
|
||||
return ItemRepository.GetItemList(query);
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query)
|
||||
|
@ -1453,31 +1434,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
|
||||
if (query.EnableTotalRecordCount)
|
||||
{
|
||||
if (!EnableCaching)
|
||||
{
|
||||
return ItemRepository.GetItems(query);
|
||||
}
|
||||
|
||||
var initialResult = ItemRepository.GetItemIds(query);
|
||||
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
TotalRecordCount = initialResult.TotalRecordCount,
|
||||
Items = initialResult.Items.Select(GetItemById).Where(i => i != null).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
if (!EnableCaching)
|
||||
{
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
Items = ItemRepository.GetItemList(query).ToArray()
|
||||
};
|
||||
return ItemRepository.GetItems(query);
|
||||
}
|
||||
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
Items = ItemRepository.GetItemIdsList(query).Select(GetItemById).Where(i => i != null).ToArray()
|
||||
Items = ItemRepository.GetItemList(query).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -155,8 +155,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)",
|
||||
"create index if not exists idx_AncestorIds2 on AncestorIds(AncestorIdText)",
|
||||
|
||||
"create table if not exists UserDataKeys (ItemId GUID, UserDataKey TEXT, PRIMARY KEY (ItemId, UserDataKey))",
|
||||
"create table if not exists UserDataKeys (ItemId GUID, UserDataKey TEXT Priority INT, PRIMARY KEY (ItemId, UserDataKey))",
|
||||
"create index if not exists idx_UserDataKeys1 on UserDataKeys(ItemId)",
|
||||
"create index if not exists idx_UserDataKeys2 on UserDataKeys(ItemId,Priority)",
|
||||
|
||||
"create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)",
|
||||
"create index if not exists idx_ItemValues on ItemValues(ItemId)",
|
||||
|
@ -270,6 +271,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
"create index if not exists idx_PresentationUniqueKey on TypedBaseItems(PresentationUniqueKey)",
|
||||
"create index if not exists idx_GuidType on TypedBaseItems(Guid,Type)",
|
||||
"create index if not exists idx_CleanNameType on TypedBaseItems(CleanName,Type)",
|
||||
"create index if not exists idx_Type on TypedBaseItems(Type)",
|
||||
"create index if not exists idx_TopParentId on TypedBaseItems(TopParentId)",
|
||||
"create index if not exists idx_TypeTopParentId on TypedBaseItems(Type,TopParentId)",
|
||||
|
|
Loading…
Reference in New Issue
Block a user