add userdata index

pull/702/head
Luke Pulverenti 9 years ago
parent f58a919488
commit e69f7b757f

@ -1276,26 +1276,22 @@ namespace MediaBrowser.Server.Implementations.Dto
{
dto.Artists = hasArtist.Artists;
dto.ArtistItems = hasArtist
.Artists
.Select(i =>
var artistItems = _libraryManager.GetArtists(new InternalItemsQuery
{
try
EnableTotalRecordCount = false,
ItemIds = new[] { item.Id.ToString("N") }
});
dto.ArtistItems = artistItems.Items
.Select(i =>
{
var artist = _libraryManager.GetArtist(i);
var artist = i.Item1;
return new NameIdPair
{
Name = artist.Name,
Id = artist.Id.ToString("N")
};
}
catch (Exception ex)
{
_logger.ErrorException("Error getting artist", ex);
return null;
}
})
.Where(i => i != null)
.ToList();
}
@ -1304,26 +1300,22 @@ namespace MediaBrowser.Server.Implementations.Dto
{
dto.AlbumArtist = hasAlbumArtist.AlbumArtists.FirstOrDefault();
dto.AlbumArtists = hasAlbumArtist
.AlbumArtists
.Select(i =>
var artistItems = _libraryManager.GetAlbumArtists(new InternalItemsQuery
{
try
EnableTotalRecordCount = false,
ItemIds = new[] { item.Id.ToString("N") }
});
dto.ArtistItems = artistItems.Items
.Select(i =>
{
var artist = _libraryManager.GetArtist(i);
var artist = i.Item1;
return new NameIdPair
{
Name = artist.Name,
Id = artist.Id.ToString("N")
};
}
catch (Exception ex)
{
_logger.ErrorException("Error getting album artist", ex);
return null;
}
})
.Where(i => i != null)
.ToList();
}

@ -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,16 +1282,9 @@ 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);
}
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
{
if (query.User != null)
@ -1426,14 +1412,9 @@ namespace MediaBrowser.Server.Implementations.Library
SetTopParentIdsOrAncestors(query, parents);
if (!EnableCaching)
{
return ItemRepository.GetItemList(query);
}
return GetItemIds(query).Select(GetItemById).Where(i => i != null);
}
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query)
{
if (query.Recursive && query.ParentId.HasValue)
@ -1452,35 +1433,16 @@ 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 new QueryResult<BaseItem>
{
Items = ItemRepository.GetItemIdsList(query).Select(GetItemById).Where(i => i != null).ToArray()
};
}
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query, IEnumerable<string> parentIds)
{
var parents = parentIds.Select(i => GetItemById(new Guid(i))).Where(i => i != null).ToList();

@ -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…
Cancel
Save