|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Core.History;
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers
|
|
|
|
|
{
|
|
|
|
@ -15,15 +14,12 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
|
|
|
|
|
public class IndexerLimitService : IIndexerLimitService
|
|
|
|
|
{
|
|
|
|
|
private readonly IEventAggregator _eventAggregator;
|
|
|
|
|
private readonly IHistoryService _historyService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public IndexerLimitService(IEventAggregator eventAggregator,
|
|
|
|
|
IHistoryService historyService,
|
|
|
|
|
Logger logger)
|
|
|
|
|
public IndexerLimitService(IHistoryService historyService,
|
|
|
|
|
Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_eventAggregator = eventAggregator;
|
|
|
|
|
_historyService = historyService;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
@ -32,14 +28,17 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
{
|
|
|
|
|
if (indexer.Id > 0 && ((IIndexerSettings)indexer.Settings).BaseSettings.GrabLimit.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var queryCount = _historyService.CountSince(indexer.Id, DateTime.Now.StartOfDay(), new List<HistoryEventType> { HistoryEventType.ReleaseGrabbed });
|
|
|
|
|
var grabCount = _historyService.CountSince(indexer.Id, DateTime.Now.StartOfDay(), new List<HistoryEventType> { HistoryEventType.ReleaseGrabbed });
|
|
|
|
|
var grabLimit = ((IIndexerSettings)indexer.Settings).BaseSettings.QueryLimit;
|
|
|
|
|
|
|
|
|
|
if (queryCount > ((IIndexerSettings)indexer.Settings).BaseSettings.GrabLimit)
|
|
|
|
|
if (grabCount > grabLimit)
|
|
|
|
|
{
|
|
|
|
|
_logger.Info("Indexer {0} has exceeded maximum grab limit for today", indexer.Name);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Indexer {0} has performed {1} of possible {2} grabs for today, proceeding", indexer.Name, grabCount, grabLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
@ -50,13 +49,16 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
if (indexer.Id > 0 && ((IIndexerSettings)indexer.Settings).BaseSettings.QueryLimit.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var queryCount = _historyService.CountSince(indexer.Id, DateTime.Now.StartOfDay(), new List<HistoryEventType> { HistoryEventType.IndexerQuery, HistoryEventType.IndexerRss });
|
|
|
|
|
var queryLimit = ((IIndexerSettings)indexer.Settings).BaseSettings.QueryLimit;
|
|
|
|
|
|
|
|
|
|
if (queryCount > ((IIndexerSettings)indexer.Settings).BaseSettings.QueryLimit)
|
|
|
|
|
if (queryCount > queryLimit)
|
|
|
|
|
{
|
|
|
|
|
_logger.Info("Indexer {0} has exceeded maximum query limit for today", indexer.Name);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Indexer {0} has performed {1} of possible {2} queries for today, proceeding", indexer.Name, queryCount, queryLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|