mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 05:47:22 -04:00
New: Add custom filter by protocol for indexer stats
This commit is contained in:
parent
ee5ed0c91b
commit
80e5ac4aa9
2 changed files with 29 additions and 2 deletions
|
@ -61,6 +61,12 @@ export const defaultState = {
|
|||
type: filterBuilderTypes.CONTAINS,
|
||||
valueType: filterBuilderValueTypes.INDEXER
|
||||
},
|
||||
{
|
||||
name: 'protocols',
|
||||
label: () => translate('Protocols'),
|
||||
type: filterBuilderTypes.EXACT,
|
||||
valueType: filterBuilderValueTypes.PROTOCOL
|
||||
},
|
||||
{
|
||||
name: 'tags',
|
||||
label: () => translate('Tags'),
|
||||
|
@ -112,6 +118,10 @@ export const actionHandlers = handleThunks({
|
|||
requestParams.indexers = selectedFilter.value.join(',');
|
||||
}
|
||||
|
||||
if (selectedFilter.key === 'protocols') {
|
||||
requestParams.protocols = selectedFilter.value.join(',');
|
||||
}
|
||||
|
||||
if (selectedFilter.key === 'tags') {
|
||||
requestParams.tags = selectedFilter.value.join(',');
|
||||
}
|
||||
|
|
|
@ -26,13 +26,30 @@ namespace Prowlarr.Api.V1.Indexers
|
|||
|
||||
[HttpGet]
|
||||
[Produces("application/json")]
|
||||
public IndexerStatsResource GetAll(DateTime? startDate, DateTime? endDate, string indexers, string tags)
|
||||
public IndexerStatsResource GetAll(DateTime? startDate, DateTime? endDate, string indexers, string protocols, string tags)
|
||||
{
|
||||
var statsStartDate = startDate ?? DateTime.MinValue;
|
||||
var statsEndDate = endDate ?? DateTime.Now;
|
||||
var parsedIndexers = new List<int>();
|
||||
var parsedTags = new List<int>();
|
||||
var indexerIds = _indexerFactory.All().Select(i => i.Id).ToList();
|
||||
|
||||
var allIndexers = _indexerFactory.All().Select(_indexerFactory.GetInstance).ToList();
|
||||
|
||||
if (protocols.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
var parsedProtocols = protocols.Split(',')
|
||||
.Select(protocol =>
|
||||
{
|
||||
Enum.TryParse(protocol, true, out DownloadProtocol downloadProtocol);
|
||||
|
||||
return downloadProtocol;
|
||||
})
|
||||
.ToHashSet();
|
||||
|
||||
allIndexers = allIndexers.Where(i => parsedProtocols.Contains(i.Protocol)).ToList();
|
||||
}
|
||||
|
||||
var indexerIds = allIndexers.Select(i => i.Definition.Id).ToList();
|
||||
|
||||
if (tags.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue