fixes #532 - Add ability to sort music artists/genres by song or music video count

pull/702/head
Luke Pulverenti 11 years ago
parent 06298d489c
commit 229e050cd3

@ -1,4 +1,5 @@
using MediaBrowser.Model.Dto; using System.Runtime.Serialization;
using MediaBrowser.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -26,8 +27,10 @@ namespace MediaBrowser.Controller.Entities.Audio
return "Artist-" + Name; return "Artist-" + Name;
} }
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; } public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
} }
} }

@ -1,4 +1,5 @@
using MediaBrowser.Model.Dto; using System.Runtime.Serialization;
using MediaBrowser.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -24,8 +25,10 @@ namespace MediaBrowser.Controller.Entities.Audio
return "MusicGenre-" + Name; return "MusicGenre-" + Name;
} }
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; } public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
} }
} }

@ -1,6 +1,7 @@
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
{ {
@ -21,8 +22,10 @@ namespace MediaBrowser.Controller.Entities
return "GameGenre-" + Name; return "GameGenre-" + Name;
} }
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; } public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
} }
} }

@ -1,4 +1,5 @@
using MediaBrowser.Model.Dto; using System.Runtime.Serialization;
using MediaBrowser.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -24,8 +25,10 @@ namespace MediaBrowser.Controller.Entities
return "Genre-" + Name; return "Genre-" + Name;
} }
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; } public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
} }
} }

@ -1,4 +1,5 @@
using MediaBrowser.Model.Dto; using System.Runtime.Serialization;
using MediaBrowser.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -15,8 +16,10 @@ namespace MediaBrowser.Controller.Entities
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
} }
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; } public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
/// <summary> /// <summary>

@ -1,4 +1,5 @@
using MediaBrowser.Model.Dto; using System.Runtime.Serialization;
using MediaBrowser.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -24,8 +25,10 @@ namespace MediaBrowser.Controller.Entities
return "Studio-" + Name; return "Studio-" + Name;
} }
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; } public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
} }
} }

@ -1,4 +1,5 @@
using MediaBrowser.Model.Dto; using System.Runtime.Serialization;
using MediaBrowser.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -15,8 +16,10 @@ namespace MediaBrowser.Controller.Entities
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
} }
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; } public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
/// <summary> /// <summary>

@ -78,5 +78,8 @@ namespace MediaBrowser.Model.Querying
public const string MovieCount = "MovieCount"; public const string MovieCount = "MovieCount";
public const string SeriesCount = "SeriesCount"; public const string SeriesCount = "SeriesCount";
public const string EpisodeCount = "EpisodeCount"; public const string EpisodeCount = "EpisodeCount";
public const string SongCount = "SongCount";
public const string AlbumCount = "AlbumCount";
public const string MusicVideoCount = "MusicVideoCount";
} }
} }

@ -181,6 +181,7 @@
<Compile Include="Session\SessionWebSocketListener.cs" /> <Compile Include="Session\SessionWebSocketListener.cs" />
<Compile Include="Sorting\AlbumArtistComparer.cs" /> <Compile Include="Sorting\AlbumArtistComparer.cs" />
<Compile Include="Sorting\AlbumComparer.cs" /> <Compile Include="Sorting\AlbumComparer.cs" />
<Compile Include="Sorting\AlbumCountComparer.cs" />
<Compile Include="Sorting\ArtistComparer.cs" /> <Compile Include="Sorting\ArtistComparer.cs" />
<Compile Include="Sorting\BudgetComparer.cs" /> <Compile Include="Sorting\BudgetComparer.cs" />
<Compile Include="Sorting\CommunityRatingComparer.cs" /> <Compile Include="Sorting\CommunityRatingComparer.cs" />
@ -191,6 +192,7 @@
<Compile Include="Sorting\IsFolderComparer.cs" /> <Compile Include="Sorting\IsFolderComparer.cs" />
<Compile Include="Sorting\IsUnplayedComparer.cs" /> <Compile Include="Sorting\IsUnplayedComparer.cs" />
<Compile Include="Sorting\MovieCountComparer.cs" /> <Compile Include="Sorting\MovieCountComparer.cs" />
<Compile Include="Sorting\MusicVideoCountComparer.cs" />
<Compile Include="Sorting\NameComparer.cs" /> <Compile Include="Sorting\NameComparer.cs" />
<Compile Include="Sorting\OfficialRatingComparer.cs" /> <Compile Include="Sorting\OfficialRatingComparer.cs" />
<Compile Include="Sorting\PlayCountComparer.cs" /> <Compile Include="Sorting\PlayCountComparer.cs" />
@ -200,6 +202,7 @@
<Compile Include="Sorting\RevenueComparer.cs" /> <Compile Include="Sorting\RevenueComparer.cs" />
<Compile Include="Sorting\RuntimeComparer.cs" /> <Compile Include="Sorting\RuntimeComparer.cs" />
<Compile Include="Sorting\SeriesCountComparer.cs" /> <Compile Include="Sorting\SeriesCountComparer.cs" />
<Compile Include="Sorting\SongCountComparer.cs" />
<Compile Include="Sorting\SortNameComparer.cs" /> <Compile Include="Sorting\SortNameComparer.cs" />
<Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" /> <Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" />
<Compile Include="Persistence\SqliteItemRepository.cs" /> <Compile Include="Persistence\SqliteItemRepository.cs" />

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Server.Implementations.Sorting
{
class AlbumCountComparer : IUserBaseItemComparer
{
/// <summary>
/// Gets or sets the user.
/// </summary>
/// <value>The user.</value>
public User User { get; set; }
/// <summary>
/// Gets or sets the user manager.
/// </summary>
/// <value>The user manager.</value>
public IUserManager UserManager { get; set; }
/// <summary>
/// Gets or sets the user data repository.
/// </summary>
/// <value>The user data repository.</value>
public IUserDataRepository UserDataRepository { get; set; }
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
return GetValue(x).CompareTo(GetValue(y));
}
/// <summary>
/// Gets the date.
/// </summary>
/// <param name="x">The x.</param>
/// <returns>DateTime.</returns>
private int GetValue(BaseItem x)
{
var itemByName = x as IItemByName;
if (itemByName != null)
{
var counts = itemByName.GetItemByNameCounts(User);
if (counts != null)
{
return counts.AlbumCount;
}
}
return 0;
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name
{
get { return ItemSortBy.AlbumCount; }
}
}
}

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Server.Implementations.Sorting
{
class MusicVideoCountComparer : IUserBaseItemComparer
{
/// <summary>
/// Gets or sets the user.
/// </summary>
/// <value>The user.</value>
public User User { get; set; }
/// <summary>
/// Gets or sets the user manager.
/// </summary>
/// <value>The user manager.</value>
public IUserManager UserManager { get; set; }
/// <summary>
/// Gets or sets the user data repository.
/// </summary>
/// <value>The user data repository.</value>
public IUserDataRepository UserDataRepository { get; set; }
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
return GetValue(x).CompareTo(GetValue(y));
}
/// <summary>
/// Gets the date.
/// </summary>
/// <param name="x">The x.</param>
/// <returns>DateTime.</returns>
private int GetValue(BaseItem x)
{
var itemByName = x as IItemByName;
if (itemByName != null)
{
var counts = itemByName.GetItemByNameCounts(User);
if (counts != null)
{
return counts.MusicVideoCount;
}
}
return 0;
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name
{
get { return ItemSortBy.MusicVideoCount; }
}
}
}

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Server.Implementations.Sorting
{
class SongCountComparer : IUserBaseItemComparer
{
/// <summary>
/// Gets or sets the user.
/// </summary>
/// <value>The user.</value>
public User User { get; set; }
/// <summary>
/// Gets or sets the user manager.
/// </summary>
/// <value>The user manager.</value>
public IUserManager UserManager { get; set; }
/// <summary>
/// Gets or sets the user data repository.
/// </summary>
/// <value>The user data repository.</value>
public IUserDataRepository UserDataRepository { get; set; }
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
return GetValue(x).CompareTo(GetValue(y));
}
/// <summary>
/// Gets the date.
/// </summary>
/// <param name="x">The x.</param>
/// <returns>DateTime.</returns>
private int GetValue(BaseItem x)
{
var itemByName = x as IItemByName;
if (itemByName != null)
{
var counts = itemByName.GetItemByNameCounts(User);
if (counts != null)
{
return counts.SongCount;
}
}
return 0;
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name
{
get { return ItemSortBy.SongCount; }
}
}
}
Loading…
Cancel
Save