Removed parameter for requesting count for tags and made including the count the default behaviour
This commit is contained in:
@@ -14,9 +14,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// </summary>
|
||||
/// <param name="objectType">Entity type</param>
|
||||
/// <param name="group">Optional group</param>
|
||||
/// <param name="withCount">Optional flag to return the number of content items tagged with the tag</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ITag> GetTagsForEntityType(TaggableObjectTypes objectType, string group = null, bool withCount = false);
|
||||
IEnumerable<ITag> GetTagsForEntityType(TaggableObjectTypes objectType, string group = null);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all tags that exist on the content item - Content/Media/Member
|
||||
|
||||
@@ -226,11 +226,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return list;
|
||||
}
|
||||
|
||||
public IEnumerable<ITag> GetTagsForEntityType(TaggableObjectTypes objectType, string group = null, bool withCount = false)
|
||||
public IEnumerable<ITag> GetTagsForEntityType(TaggableObjectTypes objectType, string group = null)
|
||||
{
|
||||
var nodeObjectType = GetNodeObjectType(objectType);
|
||||
|
||||
var sql = GetTagsQuerySelect(withCount);
|
||||
var sql = GetTagsQuerySelect(true);
|
||||
|
||||
sql = ApplyRelationshipJoinToTagsQuery(sql);
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
sql = ApplyGroupFilterToTagsQuery(sql, group);
|
||||
|
||||
sql = ApplyGroupByToTagsQuery(sql, withCount);
|
||||
sql = ApplyGroupByToTagsQuery(sql);
|
||||
|
||||
return ExecuteTagsQuery(sql);
|
||||
}
|
||||
@@ -279,11 +279,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return ExecuteTagsQuery(sql);
|
||||
}
|
||||
|
||||
private Sql GetTagsQuerySelect(bool withCount = false)
|
||||
private Sql GetTagsQuerySelect(bool withGrouping = false)
|
||||
{
|
||||
var sql = new Sql();
|
||||
|
||||
if (withCount)
|
||||
if (withGrouping)
|
||||
{
|
||||
sql = sql.Select("cmsTags.Id, cmsTags.Tag, cmsTags.[Group], Count(*) NodeCount");
|
||||
}
|
||||
@@ -313,14 +313,9 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return sql;
|
||||
}
|
||||
|
||||
private Sql ApplyGroupByToTagsQuery(Sql sql, bool withCount)
|
||||
private Sql ApplyGroupByToTagsQuery(Sql sql)
|
||||
{
|
||||
if (withCount)
|
||||
{
|
||||
sql = sql.GroupBy(new string[] { "cmsTags.Id", "cmsTags.Tag", "cmsTags.[Group]" });
|
||||
}
|
||||
|
||||
return sql;
|
||||
return sql.GroupBy(new string[] { "cmsTags.Id", "cmsTags.Tag", "cmsTags.[Group]" });
|
||||
}
|
||||
|
||||
private IEnumerable<ITag> ExecuteTagsQuery(Sql sql)
|
||||
|
||||
@@ -33,25 +33,22 @@ namespace Umbraco.Core.Services
|
||||
/// Get all tags for content items (with optional group)
|
||||
/// </summary>
|
||||
/// <param name="group">Optional group</param>
|
||||
/// <param name="withCount">Optional flag to return the number of content items tagged with the tag</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ITag> GetAllContentTags(string group = null, bool withCount = false);
|
||||
IEnumerable<ITag> GetAllContentTags(string group = null);
|
||||
|
||||
/// <summary>
|
||||
/// Get all tags for media items (with optional group)
|
||||
/// </summary>
|
||||
/// <param name="group">Optional group</param>
|
||||
/// <param name="withCount">Optional flag to return the number of content items tagged with the tag</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ITag> GetAllMediaTags(string group = null, bool withCount = false);
|
||||
IEnumerable<ITag> GetAllMediaTags(string group = null);
|
||||
|
||||
/// <summary>
|
||||
/// Get all tags for member items (with optional group)
|
||||
/// </summary>
|
||||
/// <param name="group">Optional group</param>
|
||||
/// <param name="withCount">Optional flag to return the number of content items tagged with the tag</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ITag> GetAllMemberTags(string group = null, bool withCount = false);
|
||||
IEnumerable<ITag> GetAllMemberTags(string group = null);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all tags attached to a property by entity id
|
||||
|
||||
@@ -111,13 +111,12 @@ namespace Umbraco.Core.Services
|
||||
/// Get all tags for content items (with optional group)
|
||||
/// </summary>
|
||||
/// <param name="group">Optional group</param>
|
||||
/// <param name="withCount">Optional flag to return the number of content items tagged with the tag</param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<ITag> GetAllContentTags(string group = null, bool withCount = false)
|
||||
public IEnumerable<ITag> GetAllContentTags(string group = null)
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateTagsRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
return repository.GetTagsForEntityType(TaggableObjectTypes.Content, group, withCount);
|
||||
return repository.GetTagsForEntityType(TaggableObjectTypes.Content, group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,13 +124,12 @@ namespace Umbraco.Core.Services
|
||||
/// Get all tags for media items (with optional group)
|
||||
/// </summary>
|
||||
/// <param name="group">Optional group</param>
|
||||
/// <param name="withCount">Optional flag to return the number of content items tagged with the tag</param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<ITag> GetAllMediaTags(string group = null, bool withCount = false)
|
||||
public IEnumerable<ITag> GetAllMediaTags(string group = null)
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateTagsRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
return repository.GetTagsForEntityType(TaggableObjectTypes.Media, group, withCount);
|
||||
return repository.GetTagsForEntityType(TaggableObjectTypes.Media, group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,13 +137,12 @@ namespace Umbraco.Core.Services
|
||||
/// Get all tags for member items (with optional group)
|
||||
/// </summary>
|
||||
/// <param name="group">Optional group</param>
|
||||
/// <param name="withCount">Optional flag to return the number of content items tagged with the tag</param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<ITag> GetAllMemberTags(string group = null, bool withCount = false)
|
||||
public IEnumerable<ITag> GetAllMemberTags(string group = null)
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateTagsRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
return repository.GetTagsForEntityType(TaggableObjectTypes.Member, group, withCount);
|
||||
return repository.GetTagsForEntityType(TaggableObjectTypes.Member, group);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user