Improve indexer health check messages

Fixed: Improve health check message when all enabled indexers are disabled due to failures
Closes #1551
pull/6/head
Mark McDowall 8 years ago
parent 1dab0aee6a
commit 79043f2c64

@ -23,25 +23,25 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
.Returns(new List<IIndexer> { _indexerMock.Object }); .Returns(new List<IIndexer> { _indexerMock.Object });
Mocker.GetMock<IIndexerFactory>() Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.RssEnabled()) .Setup(s => s.RssEnabled(true))
.Returns(new List<IIndexer>()); .Returns(new List<IIndexer>());
Mocker.GetMock<IIndexerFactory>() Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.SearchEnabled()) .Setup(s => s.SearchEnabled(true))
.Returns(new List<IIndexer>()); .Returns(new List<IIndexer>());
} }
private void GivenRssEnabled() private void GivenRssEnabled()
{ {
Mocker.GetMock<IIndexerFactory>() Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.RssEnabled()) .Setup(s => s.RssEnabled(true))
.Returns(new List<IIndexer> { _indexerMock.Object }); .Returns(new List<IIndexer> { _indexerMock.Object });
} }
private void GivenSearchEnabled() private void GivenSearchEnabled()
{ {
Mocker.GetMock<IIndexerFactory>() Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.SearchEnabled()) .Setup(s => s.SearchEnabled(true))
.Returns(new List<IIndexer> { _indexerMock.Object }); .Returns(new List<IIndexer> { _indexerMock.Object });
} }

@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
_mockIndexer.SetupGet(s => s.SupportsSearch).Returns(true); _mockIndexer.SetupGet(s => s.SupportsSearch).Returns(true);
Mocker.GetMock<IIndexerFactory>() Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.SearchEnabled()) .Setup(s => s.SearchEnabled(true))
.Returns(new List<IIndexer> { _mockIndexer.Object }); .Returns(new List<IIndexer> { _mockIndexer.Object });
Mocker.GetMock<IMakeDownloadDecision>() Mocker.GetMock<IMakeDownloadDecision>()

@ -36,12 +36,22 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (rssEnabled.Empty()) 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()) 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()); return new HealthCheck(GetType());

@ -9,14 +9,13 @@ namespace NzbDrone.Core.Indexers
{ {
public interface IIndexerFactory : IProviderFactory<IIndexer, IndexerDefinition> public interface IIndexerFactory : IProviderFactory<IIndexer, IndexerDefinition>
{ {
List<IIndexer> RssEnabled(); List<IIndexer> RssEnabled(bool filterBlockedIndexers = true);
List<IIndexer> SearchEnabled(); List<IIndexer> SearchEnabled(bool filterBlockedIndexers = true);
} }
public class IndexerFactory : ProviderFactory<IIndexer, IndexerDefinition>, IIndexerFactory public class IndexerFactory : ProviderFactory<IIndexer, IndexerDefinition>, IIndexerFactory
{ {
private readonly IIndexerStatusService _indexerStatusService; private readonly IIndexerStatusService _indexerStatusService;
private readonly IIndexerRepository _providerRepository;
private readonly Logger _logger; private readonly Logger _logger;
public IndexerFactory(IIndexerStatusService indexerStatusService, public IndexerFactory(IIndexerStatusService indexerStatusService,
@ -28,7 +27,6 @@ namespace NzbDrone.Core.Indexers
: base(providerRepository, providers, container, eventAggregator, logger) : base(providerRepository, providers, container, eventAggregator, logger)
{ {
_indexerStatusService = indexerStatusService; _indexerStatusService = indexerStatusService;
_providerRepository = providerRepository;
_logger = logger; _logger = logger;
} }
@ -46,22 +44,28 @@ namespace NzbDrone.Core.Indexers
definition.SupportsSearch = provider.SupportsSearch; 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 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 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) private IEnumerable<IIndexer> FilterBlockedIndexers(IEnumerable<IIndexer> indexers)

Loading…
Cancel
Save