< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Sorting.ProductionYearComparer
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
Line coverage
11%
Covered lines: 1
Uncovered lines: 8
Coverable lines: 9
Total lines: 55
Line coverage: 11.1%
Branch coverage
0%
Covered branches: 0
Total branches: 6
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%4260%

File(s)

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

#LineLine coverage
 1using Jellyfin.Data.Enums;
 2using MediaBrowser.Controller.Entities;
 3using MediaBrowser.Controller.Sorting;
 4using MediaBrowser.Model.Querying;
 5
 6namespace Emby.Server.Implementations.Sorting
 7{
 8    /// <summary>
 9    /// Class ProductionYearComparer.
 10    /// </summary>
 11    public class ProductionYearComparer : IBaseItemComparer
 12    {
 13        /// <summary>
 14        /// Gets the name.
 15        /// </summary>
 16        /// <value>The name.</value>
 117        public ItemSortBy Type => ItemSortBy.ProductionYear;
 18
 19        /// <summary>
 20        /// Compares the specified x.
 21        /// </summary>
 22        /// <param name="x">The x.</param>
 23        /// <param name="y">The y.</param>
 24        /// <returns>System.Int32.</returns>
 25        public int Compare(BaseItem? x, BaseItem? y)
 26        {
 027            return GetValue(x).CompareTo(GetValue(y));
 28        }
 29
 30        /// <summary>
 31        /// Gets the date.
 32        /// </summary>
 33        /// <param name="x">The x.</param>
 34        /// <returns>DateTime.</returns>
 35        private static int GetValue(BaseItem? x)
 36        {
 037            if (x is null)
 38            {
 039                return 0;
 40            }
 41
 042            if (x.ProductionYear.HasValue)
 43            {
 044                return x.ProductionYear.Value;
 45            }
 46
 047            if (x.PremiereDate.HasValue)
 48            {
 049                return x.PremiereDate.Value.Year;
 50            }
 51
 052            return 0;
 53        }
 54    }
 55}