remove transaction from GetItemList

pull/1154/head
Luke Pulverenti 8 years ago
parent dbba636290
commit 0f1a542c1f

@ -2548,57 +2548,53 @@ namespace Emby.Server.Implementations.Data
{
using (var connection = CreateConnection(true))
{
return connection.RunInTransaction(db =>
{
var list = new List<BaseItem>();
var list = new List<BaseItem>();
using (var statement = PrepareStatementSafe(db, commandText))
using (var statement = PrepareStatementSafe(connection, commandText))
{
if (EnableJoinUserData(query))
{
if (EnableJoinUserData(query))
{
statement.TryBind("@UserId", query.User.Id);
}
statement.TryBind("@UserId", query.User.Id);
}
BindSimilarParams(query, statement);
BindSimilarParams(query, statement);
// Running this again will bind the params
GetWhereClauses(query, statement);
// Running this again will bind the params
GetWhereClauses(query, statement);
foreach (var row in statement.ExecuteQuery())
foreach (var row in statement.ExecuteQuery())
{
var item = GetItem(row, query);
if (item != null)
{
var item = GetItem(row, query);
if (item != null)
{
list.Add(item);
}
list.Add(item);
}
}
}
// Hack for right now since we currently don't support filtering out these duplicates within a query
if (query.EnableGroupByMetadataKey)
// Hack for right now since we currently don't support filtering out these duplicates within a query
if (query.EnableGroupByMetadataKey)
{
var limit = query.Limit ?? int.MaxValue;
limit -= 4;
var newList = new List<BaseItem>();
foreach (var item in list)
{
var limit = query.Limit ?? int.MaxValue;
limit -= 4;
var newList = new List<BaseItem>();
AddItem(newList, item);
foreach (var item in list)
if (newList.Count >= limit)
{
AddItem(newList, item);
if (newList.Count >= limit)
{
break;
}
break;
}
list = newList;
}
LogQueryTime("GetItemList", commandText, now);
list = newList;
}
return list;
LogQueryTime("GetItemList", commandText, now);
}, ReadTransactionMode);
return list;
}
}
}

Loading…
Cancel
Save