< 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: 60
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.Entities;
 5using Jellyfin.Data.Enums;
 6using MediaBrowser.Controller.Entities;
 7using MediaBrowser.Controller.Library;
 8using MediaBrowser.Controller.Sorting;
 9using MediaBrowser.Model.Querying;
 10
 11namespace Emby.Server.Implementations.Sorting
 12{
 13    public class IsFavoriteOrLikeComparer : IUserBaseItemComparer
 14    {
 15        /// <summary>
 16        /// Gets or sets the user.
 17        /// </summary>
 18        /// <value>The user.</value>
 19        public User User { get; set; }
 20
 21        /// <summary>
 22        /// Gets the name.
 23        /// </summary>
 24        /// <value>The name.</value>
 125        public ItemSortBy Type => ItemSortBy.IsFavoriteOrLiked;
 26
 27        /// <summary>
 28        /// Gets or sets the user data repository.
 29        /// </summary>
 30        /// <value>The user data repository.</value>
 31        public IUserDataManager UserDataRepository { get; set; }
 32
 33        /// <summary>
 34        /// Gets or sets the user manager.
 35        /// </summary>
 36        /// <value>The user manager.</value>
 37        public IUserManager UserManager { get; set; }
 38
 39        /// <summary>
 40        /// Compares the specified x.
 41        /// </summary>
 42        /// <param name="x">The x.</param>
 43        /// <param name="y">The y.</param>
 44        /// <returns>System.Int32.</returns>
 45        public int Compare(BaseItem x, BaseItem y)
 46        {
 047            return GetValue(x).CompareTo(GetValue(y));
 48        }
 49
 50        /// <summary>
 51        /// Gets the date.
 52        /// </summary>
 53        /// <param name="x">The x.</param>
 54        /// <returns>DateTime.</returns>
 55        private int GetValue(BaseItem x)
 56        {
 057            return x.IsFavoriteOrLiked(User) ? 0 : 1;
 58        }
 59    }
 60}