< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Sorting.IsFavoriteOrLikeComparer
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
Line coverage
33%
Covered lines: 1
Uncovered lines: 2
Coverable lines: 3
Total lines: 59
Line coverage: 33.3%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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(...)100%210%

File(s)

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

#LineLine coverage
 1#nullable disable
 2#pragma warning disable CS1591
 3
 4using Jellyfin.Data.Enums;
 5using Jellyfin.Database.Implementations.Entities;
 6using MediaBrowser.Controller.Entities;
 7using MediaBrowser.Controller.Library;
 8using MediaBrowser.Controller.Sorting;
 9
 10namespace Emby.Server.Implementations.Sorting
 11{
 12    public class IsFavoriteOrLikeComparer : IUserBaseItemComparer
 13    {
 14        /// <summary>
 15        /// Gets or sets the user.
 16        /// </summary>
 17        /// <value>The user.</value>
 18        public User User { get; set; }
 19
 20        /// <summary>
 21        /// Gets the name.
 22        /// </summary>
 23        /// <value>The name.</value>
 124        public ItemSortBy Type => ItemSortBy.IsFavoriteOrLiked;
 25
 26        /// <summary>
 27        /// Gets or sets the user data manager.
 28        /// </summary>
 29        /// <value>The user data manager.</value>
 30        public IUserDataManager UserDataManager { get; set; }
 31
 32        /// <summary>
 33        /// Gets or sets the user manager.
 34        /// </summary>
 35        /// <value>The user manager.</value>
 36        public IUserManager UserManager { get; set; }
 37
 38        /// <summary>
 39        /// Compares the specified x.
 40        /// </summary>
 41        /// <param name="x">The x.</param>
 42        /// <param name="y">The y.</param>
 43        /// <returns>System.Int32.</returns>
 44        public int Compare(BaseItem x, BaseItem y)
 45        {
 046            return GetValue(x).CompareTo(GetValue(y));
 47        }
 48
 49        /// <summary>
 50        /// Gets the date.
 51        /// </summary>
 52        /// <param name="x">The x.</param>
 53        /// <returns>DateTime.</returns>
 54        private int GetValue(BaseItem x)
 55        {
 056            return x.IsFavoriteOrLiked(User, userItemData: null) ? 0 : 1;
 57        }
 58    }
 59}