Fixing #6269 by comparing PremiereDate when episode comparison would otherwise be equal.
This commit is contained in:
parent
e5cbafdb6b
commit
2b5f3f294e
|
@ -28,16 +28,6 @@ namespace Emby.Server.Implementations.Sorting
|
||||||
throw new ArgumentNullException(nameof(y));
|
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 episode1 = x as Episode;
|
||||||
var episode2 = y as Episode;
|
var episode2 = y as Episode;
|
||||||
|
|
||||||
|
@ -156,8 +146,16 @@ namespace Emby.Server.Implementations.Sorting
|
||||||
{
|
{
|
||||||
var xValue = ((x.ParentIndexNumber ?? -1) * 1000) + (x.IndexNumber ?? -1);
|
var xValue = ((x.ParentIndexNumber ?? -1) * 1000) + (x.IndexNumber ?? -1);
|
||||||
var yValue = ((y.ParentIndexNumber ?? -1) * 1000) + (y.IndexNumber ?? -1);
|
var yValue = ((y.ParentIndexNumber ?? -1) * 1000) + (y.IndexNumber ?? -1);
|
||||||
|
var compare_val = xValue.CompareTo(yValue);
|
||||||
|
if (compare_val == 0)
|
||||||
|
{
|
||||||
|
if (x.PremiereDate.HasValue & y.PremiereDate.HasValue)
|
||||||
|
{
|
||||||
|
compare_val = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return xValue.CompareTo(yValue);
|
return compare_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -172,6 +172,25 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting
|
||||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
||||||
1
|
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();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user