diff --git a/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs b/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs index fd603ece8..1af86ab1c 100644 --- a/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs +++ b/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs @@ -26,11 +26,15 @@ namespace NzbDrone.Core.IndexerStats { var history = _historyService.Between(start, end); - var filteredHistory = history.Where(h => indexerIds.Contains(h.IndexerId)); + var filteredHistory = history.Where(h => indexerIds.Contains(h.IndexerId)).ToArray(); - var groupedByIndexer = filteredHistory.GroupBy(h => h.IndexerId); - var groupedByUserAgent = filteredHistory.GroupBy(h => h.Data.GetValueOrDefault("source") ?? ""); - var groupedByHost = filteredHistory.GroupBy(h => h.Data.GetValueOrDefault("host") ?? ""); + var groupedByIndexer = filteredHistory.GroupBy(h => h.IndexerId).ToArray(); + var groupedByUserAgent = filteredHistory + .Where(h => h.EventType != HistoryEventType.IndexerAuth) + .GroupBy(h => h.Data.GetValueOrDefault("source") ?? "").ToArray(); + var groupedByHost = filteredHistory + .Where(h => h.EventType != HistoryEventType.IndexerAuth) + .GroupBy(h => h.Data.GetValueOrDefault("host") ?? "").ToArray(); var indexerStatsList = new List(); var userAgentStatsList = new List(); @@ -60,7 +64,7 @@ namespace NzbDrone.Core.IndexerStats var temp = 0; var elapsedTimeEvents = sortedEvents .Where(h => int.TryParse(h.Data.GetValueOrDefault("elapsedTime"), out temp) && h.Data.GetValueOrDefault("cached") != "1") - .Select(h => temp) + .Select(_ => temp) .ToArray(); indexerStats.AverageResponseTime = elapsedTimeEvents.Any() ? (int)elapsedTimeEvents.Average() : 0; @@ -68,6 +72,7 @@ namespace NzbDrone.Core.IndexerStats foreach (var historyEvent in sortedEvents) { var failed = !historyEvent.Successful; + switch (historyEvent.EventType) { case HistoryEventType.IndexerQuery: @@ -101,8 +106,6 @@ namespace NzbDrone.Core.IndexerStats indexerStats.NumberOfFailedRssQueries++; } - break; - default: break; } } @@ -118,8 +121,8 @@ namespace NzbDrone.Core.IndexerStats }; var sortedEvents = indexer.OrderBy(v => v.Date) - .ThenBy(v => v.Id) - .ToArray(); + .ThenBy(v => v.Id) + .ToArray(); foreach (var historyEvent in sortedEvents) { @@ -128,13 +131,10 @@ namespace NzbDrone.Core.IndexerStats case HistoryEventType.IndexerRss: case HistoryEventType.IndexerQuery: indexerStats.NumberOfQueries++; - break; case HistoryEventType.ReleaseGrabbed: indexerStats.NumberOfGrabs++; break; - default: - break; } } @@ -149,8 +149,8 @@ namespace NzbDrone.Core.IndexerStats }; var sortedEvents = indexer.OrderBy(v => v.Date) - .ThenBy(v => v.Id) - .ToArray(); + .ThenBy(v => v.Id) + .ToArray(); foreach (var historyEvent in sortedEvents) { @@ -163,8 +163,6 @@ namespace NzbDrone.Core.IndexerStats case HistoryEventType.ReleaseGrabbed: indexerStats.NumberOfGrabs++; break; - default: - break; } }