mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Improve indexer health check messages
Fixed: Improve health check message when all enabled indexers are disabled due to failures Closes #1551
This commit is contained in:
parent
1dab0aee6a
commit
79043f2c64
@ -23,25 +23,25 @@ private void GivenIndexer(bool supportsRss, bool supportsSearch)
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.RssEnabled())
|
||||
.Setup(s => s.RssEnabled(true))
|
||||
.Returns(new List<IIndexer>());
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled())
|
||||
.Setup(s => s.SearchEnabled(true))
|
||||
.Returns(new List<IIndexer>());
|
||||
}
|
||||
|
||||
private void GivenRssEnabled()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.RssEnabled())
|
||||
.Setup(s => s.RssEnabled(true))
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
}
|
||||
|
||||
private void GivenSearchEnabled()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled())
|
||||
.Setup(s => s.SearchEnabled(true))
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public void SetUp()
|
||||
_mockIndexer.SetupGet(s => s.SupportsSearch).Returns(true);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled())
|
||||
.Setup(s => s.SearchEnabled(true))
|
||||
.Returns(new List<IIndexer> { _mockIndexer.Object });
|
||||
|
||||
Mocker.GetMock<IMakeDownloadDecision>()
|
||||
|
@ -36,12 +36,22 @@ public override HealthCheck Check()
|
||||
|
||||
if (rssEnabled.Empty())
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have RSS sync enabled");
|
||||
if (_indexerFactory.RssEnabled(false).Empty())
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have RSS sync enabled");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers with RSS sync enabled are disabled due to recent failures");
|
||||
}
|
||||
|
||||
if (searchEnabled.Empty())
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have searching enabled");
|
||||
if (_indexerFactory.SearchEnabled(false).Empty())
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have searching enabled");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers with searching enabled are disabled due to recent failures");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
|
@ -9,14 +9,13 @@ namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
public interface IIndexerFactory : IProviderFactory<IIndexer, IndexerDefinition>
|
||||
{
|
||||
List<IIndexer> RssEnabled();
|
||||
List<IIndexer> SearchEnabled();
|
||||
List<IIndexer> RssEnabled(bool filterBlockedIndexers = true);
|
||||
List<IIndexer> SearchEnabled(bool filterBlockedIndexers = true);
|
||||
}
|
||||
|
||||
public class IndexerFactory : ProviderFactory<IIndexer, IndexerDefinition>, IIndexerFactory
|
||||
{
|
||||
private readonly IIndexerStatusService _indexerStatusService;
|
||||
private readonly IIndexerRepository _providerRepository;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public IndexerFactory(IIndexerStatusService indexerStatusService,
|
||||
@ -28,7 +27,6 @@ public IndexerFactory(IIndexerStatusService indexerStatusService,
|
||||
: base(providerRepository, providers, container, eventAggregator, logger)
|
||||
{
|
||||
_indexerStatusService = indexerStatusService;
|
||||
_providerRepository = providerRepository;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@ -46,22 +44,28 @@ public override void SetProviderCharacteristics(IIndexer provider, IndexerDefini
|
||||
definition.SupportsSearch = provider.SupportsSearch;
|
||||
}
|
||||
|
||||
public List<IIndexer> RssEnabled()
|
||||
public List<IIndexer> RssEnabled(bool filterBlockedIndexers = true)
|
||||
{
|
||||
var enabledIndexers = GetAvailableProviders().Where(n => ((IndexerDefinition)n.Definition).EnableRss);
|
||||
|
||||
var indexers = FilterBlockedIndexers(enabledIndexers);
|
||||
if (filterBlockedIndexers)
|
||||
{
|
||||
return FilterBlockedIndexers(enabledIndexers).ToList();
|
||||
}
|
||||
|
||||
return indexers.ToList();
|
||||
return enabledIndexers.ToList();
|
||||
}
|
||||
|
||||
public List<IIndexer> SearchEnabled()
|
||||
public List<IIndexer> SearchEnabled(bool filterBlockedIndexers = true)
|
||||
{
|
||||
var enabledIndexers = GetAvailableProviders().Where(n => ((IndexerDefinition)n.Definition).EnableSearch);
|
||||
|
||||
var indexers = FilterBlockedIndexers(enabledIndexers);
|
||||
if (filterBlockedIndexers)
|
||||
{
|
||||
return FilterBlockedIndexers(enabledIndexers).ToList();
|
||||
}
|
||||
|
||||
return indexers.ToList();
|
||||
return enabledIndexers.ToList();
|
||||
}
|
||||
|
||||
private IEnumerable<IIndexer> FilterBlockedIndexers(IEnumerable<IIndexer> indexers)
|
||||
|
Loading…
Reference in New Issue
Block a user