< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Sorting.StartDateComparer
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Sorting/StartDateComparer.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 46
Line coverage: 0%
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%210%
Compare(...)100%210%
GetDate(...)0%620%

File(s)

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

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System;
 4using Jellyfin.Data.Enums;
 5using MediaBrowser.Controller.Entities;
 6using MediaBrowser.Controller.LiveTv;
 7using MediaBrowser.Controller.Sorting;
 8using MediaBrowser.Model.Querying;
 9
 10namespace Emby.Server.Implementations.Sorting
 11{
 12    public class StartDateComparer : IBaseItemComparer
 13    {
 14        /// <summary>
 15        /// Gets the name.
 16        /// </summary>
 17        /// <value>The name.</value>
 018        public ItemSortBy Type => ItemSortBy.StartDate;
 19
 20        /// <summary>
 21        /// Compares the specified x.
 22        /// </summary>
 23        /// <param name="x">The x.</param>
 24        /// <param name="y">The y.</param>
 25        /// <returns>System.Int32.</returns>
 26        public int Compare(BaseItem? x, BaseItem? y)
 27        {
 028            return GetDate(x).CompareTo(GetDate(y));
 29        }
 30
 31        /// <summary>
 32        /// Gets the date.
 33        /// </summary>
 34        /// <param name="x">The x.</param>
 35        /// <returns>DateTime.</returns>
 36        private static DateTime GetDate(BaseItem? x)
 37        {
 038            if (x is LiveTvProgram hasStartDate)
 39            {
 040                return hasStartDate.StartDate;
 41            }
 42
 043            return DateTime.MinValue;
 44        }
 45    }
 46}