You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/src/Prowlarr.Api.V1/Indexers/IndexerStatsController.cs

38 lines
1.1 KiB

using System;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.IndexerStats;
using Prowlarr.Http;
namespace Prowlarr.Api.V1.Indexers
{
[V1ApiController]
public class IndexerStatsController : Controller
{
private readonly IIndexerStatisticsService _indexerStatisticsService;
public IndexerStatsController(IIndexerStatisticsService indexerStatisticsService)
{
_indexerStatisticsService = indexerStatisticsService;
}
[HttpGet]
[Produces("application/json")]
public IndexerStatsResource GetAll(DateTime? startDate, DateTime? endDate)
{
var statsStartDate = startDate ?? DateTime.MinValue;
var statsEndDate = endDate ?? DateTime.Now;
var indexerStats = _indexerStatisticsService.IndexerStatistics(statsStartDate, statsEndDate);
var indexerResource = new IndexerStatsResource
{
Indexers = indexerStats.IndexerStatistics,
UserAgents = indexerStats.UserAgentStatistics,
Hosts = indexerStats.HostStatistics
};
return indexerResource;
}
}
}