Improve indexer health check messages (#1015)

* Improve indexer health check messages

Fixed: Improve health check message when all enabled indexers are disabled due to failures
Closes #1551

* Fixed: Health check failing and preventing others from running

* Fixed Indexer Health Checks and tests.
This commit is contained in:
Mitchell Cash
2017-03-05 17:50:45 +10:00
committed by Devin Buhl
parent 7433e89467
commit 9787cf6cdd
15 changed files with 273 additions and 150 deletions

View File

@@ -0,0 +1,35 @@
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
namespace NzbDrone.Core.HealthCheck.Checks
{
public class IndexerSearchCheck : HealthCheckBase
{
private readonly IIndexerFactory _indexerFactory;
public IndexerSearchCheck(IIndexerFactory indexerFactory)
{
_indexerFactory = indexerFactory;
}
public override HealthCheck Check()
{
var enabled = _indexerFactory.SearchEnabled(false);
if (enabled.Empty())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Search enabled, Sonarr will not provide any search results");
}
var active = _indexerFactory.SearchEnabled(true);
if (active.Empty())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "All search-capable indexers are temporarily unavailable due to recent indexer errors");
}
return new HealthCheck(GetType());
}
}
}