mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-09 05:22:09 +02:00
Grab Stats
This commit is contained in:
parent
79c96b86a4
commit
783c29ef80
8 changed files with 41 additions and 10 deletions
|
|
@ -30,6 +30,21 @@ function getTotalRequestsData(indexerStats) {
|
|||
return data;
|
||||
}
|
||||
|
||||
function getNumberGrabsData(indexerStats) {
|
||||
const data = indexerStats.map((indexer) => {
|
||||
return {
|
||||
label: indexer.indexerName,
|
||||
value: indexer.numberOfGrabs
|
||||
};
|
||||
});
|
||||
|
||||
data.sort((a, b) => {
|
||||
return b.value - a.value;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function Stats(props) {
|
||||
const {
|
||||
items,
|
||||
|
|
@ -70,6 +85,12 @@ function Stats(props) {
|
|||
title='Total Indexer Queries'
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.halfWidthChart}>
|
||||
<BarChart
|
||||
data={getNumberGrabsData(items)}
|
||||
title='Total Indexer Grabs'
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</PageContent>
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ public void Handle(IndexerDownloadEvent message)
|
|||
};
|
||||
|
||||
history.Data.Add("Successful", message.Successful.ToString());
|
||||
history.Data.Add("Source", message.Source ?? string.Empty);
|
||||
|
||||
_historyRepository.Insert(history);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@ public class IndexerStatistics : ResultSet
|
|||
public string IndexerName { get; set; }
|
||||
public int AverageResponseTime { get; set; }
|
||||
public int NumberOfQueries { get; set; }
|
||||
public int NumberOfGrabs { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ private List<IndexerStatistics> Query(SqlBuilder builder)
|
|||
private SqlBuilder Builder() => new SqlBuilder()
|
||||
.Select(@"Indexers.Id AS IndexerId,
|
||||
Indexers.Name AS IndexerName,
|
||||
COUNT(History.Id) AS NumberOfQueries,
|
||||
SUM(CASE WHEN EventType == 2 then 1 else 0 end) AS NumberOfQueries,
|
||||
SUM(CASE WHEN EventType == 1 then 1 else 0 end) AS NumberOfGrabs,
|
||||
AVG(json_extract(History.Data,'$.elapsedTime')) AS AverageResponseTime")
|
||||
.Join<History.History, IndexerDefinition>((t, r) => t.IndexerId == r.Id)
|
||||
.GroupBy<IndexerDefinition>(x => x.Id);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Indexers
|
|||
{
|
||||
public interface IDownloadService
|
||||
{
|
||||
byte[] DownloadReport(string link, int indexerId);
|
||||
byte[] DownloadReport(string link, int indexerId, string source);
|
||||
}
|
||||
|
||||
public class DownloadService : IDownloadService
|
||||
|
|
@ -37,7 +37,7 @@ public DownloadService(IIndexerFactory indexerFactory,
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public byte[] DownloadReport(string link, int indexerId)
|
||||
public byte[] DownloadReport(string link, int indexerId, string source)
|
||||
{
|
||||
var url = new HttpUri(link);
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public byte[] DownloadReport(string link, int indexerId)
|
|||
}
|
||||
|
||||
var indexer = _indexerFactory.GetInstance(_indexerFactory.Get(indexerId));
|
||||
bool success;
|
||||
var success = false;
|
||||
var downloadedBytes = Array.Empty<byte>();
|
||||
|
||||
try
|
||||
|
|
@ -60,7 +60,7 @@ public byte[] DownloadReport(string link, int indexerId)
|
|||
catch (ReleaseUnavailableException)
|
||||
{
|
||||
_logger.Trace("Release {0} no longer available on indexer.", link);
|
||||
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, false));
|
||||
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source));
|
||||
throw;
|
||||
}
|
||||
catch (ReleaseDownloadException ex)
|
||||
|
|
@ -75,11 +75,11 @@ public byte[] DownloadReport(string link, int indexerId)
|
|||
_indexerStatusService.RecordFailure(indexerId);
|
||||
}
|
||||
|
||||
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, false));
|
||||
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source));
|
||||
throw;
|
||||
}
|
||||
|
||||
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success));
|
||||
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source));
|
||||
return downloadedBytes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ public class IndexerDownloadEvent : IEvent
|
|||
{
|
||||
public int IndexerId { get; set; }
|
||||
public bool Successful { get; set; }
|
||||
public string Source { get; set; }
|
||||
|
||||
public IndexerDownloadEvent(int indexerId, bool successful)
|
||||
public IndexerDownloadEvent(int indexerId, bool successful, string source)
|
||||
{
|
||||
IndexerId = indexerId;
|
||||
Successful = successful;
|
||||
Source = source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Nancy;
|
||||
using Nancy.ModelBinding;
|
||||
|
|
@ -115,8 +116,10 @@ private object GetDownload(int id)
|
|||
|
||||
var indexerInstance = _indexerFactory.GetInstance(indexer);
|
||||
|
||||
var source = UserAgentParser.ParseSource(Request.Headers.UserAgent);
|
||||
|
||||
var downloadBytes = Array.Empty<byte>();
|
||||
downloadBytes = _downloadService.DownloadReport(_downloadMappingService.ConvertToNormalLink(link), id);
|
||||
downloadBytes = _downloadService.DownloadReport(_downloadMappingService.ConvertToNormalLink(link), id, source);
|
||||
|
||||
// handle magnet URLs
|
||||
if (downloadBytes.Length >= 7
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class IndexerStatsResource : RestResource
|
|||
public string IndexerName { get; set; }
|
||||
public int NumberOfQueries { get; set; }
|
||||
public int AverageResponseTime { get; set; }
|
||||
public int NumberOfGrabs { get; set; }
|
||||
}
|
||||
|
||||
public static class IndexerStatsResourceMapper
|
||||
|
|
@ -27,7 +28,8 @@ public static IndexerStatsResource ToResource(this IndexerStatistics model)
|
|||
IndexerId = model.IndexerId,
|
||||
IndexerName = model.IndexerName,
|
||||
NumberOfQueries = model.NumberOfQueries,
|
||||
AverageResponseTime = model.AverageResponseTime
|
||||
AverageResponseTime = model.AverageResponseTime,
|
||||
NumberOfGrabs = model.NumberOfGrabs
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue