< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Sorting.DateLastMediaAddedComparer
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 49
Line coverage: 83.3%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/1/2026 - 12:13:05 AM Line coverage: 16.6% (1/6) Branch coverage: 0% (0/4) Total lines: 697/26/2026 - 12:17:51 AM Line coverage: 83.3% (5/6) Branch coverage: 50% (2/4) Total lines: 49 5/1/2026 - 12:13:05 AM Line coverage: 16.6% (1/6) Branch coverage: 0% (0/4) Total lines: 697/26/2026 - 12:17:51 AM Line coverage: 83.3% (5/6) Branch coverage: 50% (2/4) Total lines: 49

Coverage delta

Coverage delta 67 -67

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Type()100%11100%
Compare(...)100%11100%
GetDate(...)50%4475%

File(s)

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

#LineLine coverage
 1#nullable disable
 2#pragma warning disable CS1591
 3
 4using System;
 5using Jellyfin.Data.Enums;
 6using MediaBrowser.Controller.Entities;
 7using MediaBrowser.Controller.Sorting;
 8using MediaBrowser.Model.Querying;
 9
 10namespace Emby.Server.Implementations.Sorting
 11{
 12    public class DateLastMediaAddedComparer : IBaseItemComparer
 13    {
 14        /// <summary>
 15        /// Gets the name.
 16        /// </summary>
 17        /// <value>The name.</value>
 218        public ItemSortBy Type => ItemSortBy.DateLastContentAdded;
 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        {
 328            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        {
 638            if (x is Folder folder)
 39            {
 640                if (folder.DateLastMediaAdded.HasValue)
 41                {
 642                    return folder.DateLastMediaAdded.Value;
 43                }
 44            }
 45
 046            return DateTime.MinValue;
 47        }
 48    }
 49}