< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Sorting.PlayCountComparer
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
Line coverage
25%
Covered lines: 1
Uncovered lines: 3
Coverable lines: 4
Total lines: 64
Line coverage: 25%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Type()100%11100%
Compare(...)100%210%
GetValue(...)0%620%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Sorting/PlayCountComparer.cs

#LineLine coverage
 1#nullable disable
 2
 3using Jellyfin.Data.Entities;
 4using Jellyfin.Data.Enums;
 5using MediaBrowser.Controller.Entities;
 6using MediaBrowser.Controller.Library;
 7using MediaBrowser.Controller.Sorting;
 8using MediaBrowser.Model.Querying;
 9
 10namespace Emby.Server.Implementations.Sorting
 11{
 12    /// <summary>
 13    /// Class PlayCountComparer.
 14    /// </summary>
 15    public class PlayCountComparer : IUserBaseItemComparer
 16    {
 17        /// <summary>
 18        /// Gets or sets the user.
 19        /// </summary>
 20        /// <value>The user.</value>
 21        public User User { get; set; }
 22
 23        /// <summary>
 24        /// Gets the name.
 25        /// </summary>
 26        /// <value>The name.</value>
 127        public ItemSortBy Type => ItemSortBy.PlayCount;
 28
 29        /// <summary>
 30        /// Gets or sets the user data repository.
 31        /// </summary>
 32        /// <value>The user data repository.</value>
 33        public IUserDataManager UserDataRepository { get; set; }
 34
 35        /// <summary>
 36        /// Gets or sets the user manager.
 37        /// </summary>
 38        /// <value>The user manager.</value>
 39        public IUserManager UserManager { get; set; }
 40
 41        /// <summary>
 42        /// Compares the specified x.
 43        /// </summary>
 44        /// <param name="x">The x.</param>
 45        /// <param name="y">The y.</param>
 46        /// <returns>System.Int32.</returns>
 47        public int Compare(BaseItem x, BaseItem y)
 48        {
 049            return GetValue(x).CompareTo(GetValue(y));
 50        }
 51
 52        /// <summary>
 53        /// Gets the date.
 54        /// </summary>
 55        /// <param name="x">The x.</param>
 56        /// <returns>DateTime.</returns>
 57        private int GetValue(BaseItem x)
 58        {
 059            var userdata = UserDataRepository.GetUserData(User, x);
 60
 061            return userdata is null ? 0 : userdata.PlayCount;
 62        }
 63    }
 64}