remove duplicate functions

This commit is contained in:
crobibero 2020-07-06 10:02:16 -06:00
parent b2e7a4a1cb
commit 1bf131c109

View File

@ -147,57 +147,6 @@ namespace Jellyfin.Api.Helpers
.ToArray();
}
/// <summary>
/// Get orderby.
/// </summary>
/// <param name="sortBy">Sort by.</param>
/// <param name="requestedSortOrder">Sort order.</param>
/// <returns>Resulting order by.</returns>
internal static ValueTuple<string, SortOrder>[] GetOrderBy(string? sortBy, string? requestedSortOrder)
{
if (string.IsNullOrEmpty(sortBy))
{
return Array.Empty<ValueTuple<string, SortOrder>>();
}
var vals = sortBy.Split(',');
if (string.IsNullOrWhiteSpace(requestedSortOrder))
{
requestedSortOrder = "Ascending";
}
var sortOrders = requestedSortOrder.Split(',');
var result = new ValueTuple<string, SortOrder>[vals.Length];
for (var i = 0; i < vals.Length; i++)
{
var sortOrderIndex = sortOrders.Length > i ? i : 0;
var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null;
var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase)
? SortOrder.Descending
: SortOrder.Ascending;
result[i] = new ValueTuple<string, SortOrder>(vals[i], sortOrder);
}
return result;
}
/// <summary>
/// Gets the filters.
/// </summary>
/// <param name="filters">The filter string.</param>
/// <returns>IEnumerable{ItemFilter}.</returns>
internal static ItemFilter[] GetFilters(string filters)
{
return string.IsNullOrEmpty(filters)
? Array.Empty<ItemFilter>()
: Split(filters, ',', true)
.Select(v => Enum.Parse<ItemFilter>(v, true)).ToArray();
}
/// <summary>
/// Gets the item fields.
/// </summary>