Merge pull request #1852 from MediaBrowser/dev

Dev
pull/702/head
Luke 9 years ago committed by GitHub
commit 6a47d51fad

@ -666,6 +666,27 @@ namespace MediaBrowser.Controller.Entities
}); });
} }
public virtual int GetChildCount(User user)
{
if (LinkedChildren.Count > 0)
{
if (!(this is ICollectionFolder))
{
return GetChildren(user, true).Count();
}
}
var result = GetItems(new InternalItemsQuery(user)
{
Recursive = false,
Limit = 0,
ParentId = Id
}).Result;
return result.TotalRecordCount;
}
public QueryResult<BaseItem> QueryRecursive(InternalItemsQuery query) public QueryResult<BaseItem> QueryRecursive(InternalItemsQuery query)
{ {
var user = query.User; var user = query.User;

@ -75,6 +75,11 @@ namespace MediaBrowser.Controller.Entities.TV
return list; return list;
} }
public override int GetChildCount(User user)
{
return GetChildren(user, true).Count();
}
/// <summary> /// <summary>
/// This Episode's Series Instance /// This Episode's Series Instance
/// </summary> /// </summary>

@ -111,6 +111,20 @@ namespace MediaBrowser.Controller.Entities.TV
} }
} }
public override int GetChildCount(User user)
{
var result = LibraryManager.GetItemsResult(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = PresentationUniqueKey,
IncludeItemTypes = new[] { typeof(Season).Name },
SortBy = new[] { ItemSortBy.SortName },
IsVirtualItem = false,
Limit = 0
});
return result.TotalRecordCount;
}
/// <summary> /// <summary>
/// Gets the user data key. /// Gets the user data key.
/// </summary> /// </summary>

@ -38,6 +38,11 @@ namespace MediaBrowser.Controller.Entities
return PostFilterAndSort(result.Where(filter), query); return PostFilterAndSort(result.Where(filter), query);
} }
public override int GetChildCount(User user)
{
return GetChildren(user, true).Count();
}
[IgnoreDataMember] [IgnoreDataMember]
protected override bool SupportsShortcutChildren protected override bool SupportsShortcutChildren
{ {

@ -45,6 +45,11 @@ namespace MediaBrowser.Controller.Entities
return list; return list;
} }
public override int GetChildCount(User user)
{
return GetChildren(user, true).Count();
}
protected override Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query) protected override Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query)
{ {
var parent = this as Folder; var parent = this as Folder;

@ -150,13 +150,6 @@ namespace MediaBrowser.Controller.Library
/// <returns>BaseItem.</returns> /// <returns>BaseItem.</returns>
BaseItem GetItemById(Guid id); BaseItem GetItemById(Guid id);
/// <summary>
/// Gets the memory item by identifier.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>BaseItem.</returns>
BaseItem GetMemoryItemById(Guid id);
/// <summary> /// <summary>
/// Gets the intros. /// Gets the intros.
/// </summary> /// </summary>

@ -21,8 +21,8 @@ namespace MediaBrowser.Dlna.Profiles
new HttpHeaderInfo new HttpHeaderInfo
{ {
Name = "User-Agent", Name = "User-Agent",
Value = @"SEC_", Value = @".*(SEC_HHP_\[TV\] [A-Z]{2}\d{2}J[A-Z]?\d{3,4})*.",
Match = HeaderMatchType.Substring Match = HeaderMatchType.Regex
} }
} }
}; };

@ -4,7 +4,7 @@
<Identification> <Identification>
<ModelUrl>samsung.com</ModelUrl> <ModelUrl>samsung.com</ModelUrl>
<Headers> <Headers>
<HttpHeaderInfo name="User-Agent" value="SEC_" match="Substring" /> <HttpHeaderInfo name="User-Agent" value=".*(SEC_HHP_\[TV\] [A-Z]{2}\d{2}J[A-Z]?\d{3,4})*." match="Regex" />
</Headers> </Headers>
</Identification> </Identification>
<Manufacturer>Emby</Manufacturer> <Manufacturer>Emby</Manufacturer>

@ -307,7 +307,6 @@ namespace MediaBrowser.Providers.Music
} }
var nodes = releaseList.ChildNodes; var nodes = releaseList.ChildNodes;
string releaseGroupId = null;
if (nodes != null) if (nodes != null)
{ {

@ -549,8 +549,7 @@ namespace MediaBrowser.Server.Implementations.Dto
private int GetChildCount(Folder folder, User user) private int GetChildCount(Folder folder, User user)
{ {
return folder.GetChildren(user, true) return folder.GetChildCount(user);
.Count();
} }
/// <summary> /// <summary>

@ -1276,18 +1276,9 @@ namespace MediaBrowser.Server.Implementations.Library
return item; return item;
} }
public BaseItem GetMemoryItemById(Guid id) private bool EnableCaching
{ {
if (id == Guid.Empty) get { return true; }
{
throw new ArgumentNullException("id");
}
BaseItem item;
LibraryItemsCache.TryGetValue(id, out item);
return item;
} }
public IEnumerable<BaseItem> GetItemList(InternalItemsQuery query) public IEnumerable<BaseItem> GetItemList(InternalItemsQuery query)
@ -1297,6 +1288,11 @@ namespace MediaBrowser.Server.Implementations.Library
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
if (!EnableCaching)
{
return ItemRepository.GetItemList(query);
}
var result = ItemRepository.GetItemIdsList(query); var result = ItemRepository.GetItemIdsList(query);
return result.Select(GetItemById).Where(i => i != null); return result.Select(GetItemById).Where(i => i != null);
@ -1336,6 +1332,11 @@ namespace MediaBrowser.Server.Implementations.Library
SetTopParentIdsOrAncestors(query, parents); SetTopParentIdsOrAncestors(query, parents);
if (!EnableCaching)
{
return ItemRepository.GetItemList(query);
}
return GetItemIds(query).Select(GetItemById).Where(i => i != null); return GetItemIds(query).Select(GetItemById).Where(i => i != null);
} }
@ -1358,6 +1359,11 @@ namespace MediaBrowser.Server.Implementations.Library
if (query.EnableTotalRecordCount) if (query.EnableTotalRecordCount)
{ {
if (!EnableCaching)
{
return ItemRepository.GetItems(query);
}
var initialResult = ItemRepository.GetItemIds(query); var initialResult = ItemRepository.GetItemIds(query);
return new QueryResult<BaseItem> return new QueryResult<BaseItem>
@ -1367,6 +1373,14 @@ namespace MediaBrowser.Server.Implementations.Library
}; };
} }
if (!EnableCaching)
{
return new QueryResult<BaseItem>
{
Items = ItemRepository.GetItemList(query).ToArray()
};
}
return new QueryResult<BaseItem> return new QueryResult<BaseItem>
{ {
Items = ItemRepository.GetItemIdsList(query).Select(GetItemById).Where(i => i != null).ToArray() Items = ItemRepository.GetItemIdsList(query).Select(GetItemById).Where(i => i != null).ToArray()

@ -122,7 +122,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
protected override async Task<IDbConnection> CreateConnection(bool isReadOnly = false) protected override async Task<IDbConnection> CreateConnection(bool isReadOnly = false)
{ {
var connection = await DbConnector.Connect(DbFilePath, false, false, 20000).ConfigureAwait(false); var connection = await DbConnector.Connect(DbFilePath, false, false, 5000).ConfigureAwait(false);
connection.RunQueries(new[] connection.RunQueries(new[]
{ {

Loading…
Cancel
Save