Fixed: Indexer sort is case sensitive

This commit is contained in:
Qstick
2021-06-01 21:56:35 -04:00
parent e999b869a6
commit 56850aa6d9
7 changed files with 27 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ function IndexerIndexSortMenu(props) {
</SortMenuItem> </SortMenuItem>
<SortMenuItem <SortMenuItem
name="name" name="sortName"
sortKey={sortKey} sortKey={sortKey}
sortDirection={sortDirection} sortDirection={sortDirection}
onPress={onSortSelect} onPress={onSortSelect}

View File

@@ -4,7 +4,7 @@
flex: 0 0 60px; flex: 0 0 60px;
} }
.name { .sortName {
composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css';
flex: 4 0 110px; flex: 4 0 110px;

View File

@@ -11,7 +11,7 @@
flex: 0 0 60px; flex: 0 0 60px;
} }
.name { .sortName {
composes: cell; composes: cell;
flex: 4 0 110px; flex: 4 0 110px;

View File

@@ -136,7 +136,7 @@ class IndexerIndexRow extends Component {
); );
} }
if (column.name === 'name') { if (column.name === 'sortName') {
return ( return (
<VirtualTableRowCell <VirtualTableRowCell
key={column.name} key={column.name}

View File

@@ -24,9 +24,9 @@ export const defaultState = {
saveError: null, saveError: null,
isDeleting: false, isDeleting: false,
deleteError: null, deleteError: null,
sortKey: 'name', sortKey: 'sortName',
sortDirection: sortDirections.ASCENDING, sortDirection: sortDirections.ASCENDING,
secondarySortKey: 'name', secondarySortKey: 'sortName',
secondarySortDirection: sortDirections.ASCENDING, secondarySortDirection: sortDirections.ASCENDING,
tableOptions: { tableOptions: {
@@ -50,7 +50,7 @@ export const defaultState = {
isModifiable: false isModifiable: false
}, },
{ {
name: 'name', name: 'sortName',
label: 'Indexer Name', label: 'Indexer Name',
isSortable: true, isSortable: true,
isVisible: true, isVisible: true,

View File

@@ -15,6 +15,12 @@ namespace NzbDrone.Core.Parser
{ {
public static class StringUtil public static class StringUtil
{ {
private static readonly Regex WordDelimiterRegex = new Regex(@"(\s|\.|,|_|-|=|'|\|)+", RegexOptions.Compiled);
private static readonly Regex SpecialCharRegex = new Regex(@"(\&|\:|\\|\/)+", RegexOptions.Compiled);
private static readonly Regex PunctuationRegex = new Regex(@"[^\w\s]", RegexOptions.Compiled);
private static readonly Regex CommonWordRegex = new Regex(@"\b(a|an|the|and|or|of)\b\s?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex DuplicateSpacesRegex = new Regex(@"\s{2,}", RegexOptions.Compiled);
public static string CleanFileName(string name, bool replace = true) public static string CleanFileName(string name, bool replace = true)
{ {
string result = name; string result = name;
@@ -248,5 +254,16 @@ namespace NzbDrone.Core.Parser
return key; return key;
} }
} }
public static string NormalizeTitle(this string title)
{
title = WordDelimiterRegex.Replace(title, " ");
title = PunctuationRegex.Replace(title, string.Empty);
title = CommonWordRegex.Replace(title, string.Empty);
title = DuplicateSpacesRegex.Replace(title, " ");
title = SpecialCharRegex.Replace(title, string.Empty);
return title.Trim().ToLower();
}
} }
} }

View File

@@ -7,6 +7,7 @@ using NzbDrone.Core.Annotations;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Cardigann; using NzbDrone.Core.Indexers.Cardigann;
using NzbDrone.Core.IndexerVersions; using NzbDrone.Core.IndexerVersions;
using NzbDrone.Core.Parser;
using Prowlarr.Http.ClientSchema; using Prowlarr.Http.ClientSchema;
namespace Prowlarr.Api.V1.Indexers namespace Prowlarr.Api.V1.Indexers
@@ -29,6 +30,7 @@ namespace Prowlarr.Api.V1.Indexers
public int Priority { get; set; } public int Priority { get; set; }
public DateTime Added { get; set; } public DateTime Added { get; set; }
public IndexerStatusResource Status { get; set; } public IndexerStatusResource Status { get; set; }
public string SortName { get; set; }
} }
public class IndexerResourceMapper : ProviderResourceMapper<IndexerResource, IndexerDefinition> public class IndexerResourceMapper : ProviderResourceMapper<IndexerResource, IndexerDefinition>
@@ -81,6 +83,7 @@ namespace Prowlarr.Api.V1.Indexers
resource.Privacy = definition.Privacy; resource.Privacy = definition.Privacy;
resource.Priority = definition.Priority; resource.Priority = definition.Priority;
resource.Added = definition.Added; resource.Added = definition.Added;
resource.SortName = definition.Name.NormalizeTitle();
return resource; return resource;
} }