Merge pull request #6553 from ankenyr/master
This commit is contained in:
commit
c38d19682c
|
@ -28,16 +28,6 @@ namespace Emby.Server.Implementations.Sorting
|
|||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
|
||||
if (x.PremiereDate.HasValue && y.PremiereDate.HasValue)
|
||||
{
|
||||
var val = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value);
|
||||
|
||||
if (val != 0)
|
||||
{
|
||||
// return val;
|
||||
}
|
||||
}
|
||||
|
||||
var episode1 = x as Episode;
|
||||
var episode2 = y as Episode;
|
||||
|
||||
|
@ -156,8 +146,14 @@ namespace Emby.Server.Implementations.Sorting
|
|||
{
|
||||
var xValue = ((x.ParentIndexNumber ?? -1) * 1000) + (x.IndexNumber ?? -1);
|
||||
var yValue = ((y.ParentIndexNumber ?? -1) * 1000) + (y.IndexNumber ?? -1);
|
||||
var comparisonResult = xValue.CompareTo(yValue);
|
||||
// If equal, compare premiere dates
|
||||
if (comparisonResult == 0 && x.PremiereDate.HasValue && y.PremiereDate.HasValue)
|
||||
{
|
||||
comparisonResult = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value);
|
||||
}
|
||||
|
||||
return xValue.CompareTo(yValue);
|
||||
return comparisonResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -172,6 +172,25 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting
|
|||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
||||
1
|
||||
};
|
||||
// Premiere Date
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1, PremiereDate = new DateTime(2021, 09, 12, 0, 0, 0) },
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1, PremiereDate = new DateTime(2021, 09, 12, 0, 0, 0) },
|
||||
0
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1, PremiereDate = new DateTime(2021, 09, 11, 0, 0, 0) },
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1, PremiereDate = new DateTime(2021, 09, 12, 0, 0, 0) },
|
||||
-1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1, PremiereDate = new DateTime(2021, 09, 12, 0, 0, 0) },
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1, PremiereDate = new DateTime(2021, 09, 11, 0, 0, 0) },
|
||||
1
|
||||
};
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
|
Loading…
Reference in New Issue
Block a user