Use method group in History controller

pull/1852/head
Bogdan 1 year ago
parent ba3ebc7574
commit 4410636b97

@ -19,13 +19,6 @@ namespace Prowlarr.Api.V1.History
_historyService = historyService;
}
protected HistoryResource MapToResource(NzbDrone.Core.History.History model)
{
var resource = model.ToResource();
return resource;
}
[HttpGet]
[Produces("application/json")]
public PagingResource<HistoryResource> GetHistory()
@ -55,14 +48,14 @@ namespace Prowlarr.Api.V1.History
pagingSpec.FilterExpressions.Add(h => h.DownloadId == downloadId);
}
return pagingSpec.ApplyToPage(_historyService.Paged, h => MapToResource(h));
return pagingSpec.ApplyToPage(_historyService.Paged, MapToResource);
}
[HttpGet("since")]
[Produces("application/json")]
public List<HistoryResource> GetHistorySince(DateTime date, HistoryEventType? eventType = null)
{
return _historyService.Since(date, eventType).Select(h => MapToResource(h)).ToList();
return _historyService.Since(date, eventType).Select(MapToResource).ToList();
}
[HttpGet("indexer")]
@ -71,10 +64,15 @@ namespace Prowlarr.Api.V1.History
{
if (limit.HasValue)
{
return _historyService.GetByIndexerId(indexerId, eventType).Select(h => MapToResource(h)).Take(limit.Value).ToList();
return _historyService.GetByIndexerId(indexerId, eventType).Select(MapToResource).Take(limit.Value).ToList();
}
return _historyService.GetByIndexerId(indexerId, eventType).Select(h => MapToResource(h)).ToList();
return _historyService.GetByIndexerId(indexerId, eventType).Select(MapToResource).ToList();
}
protected HistoryResource MapToResource(NzbDrone.Core.History.History model)
{
return model.ToResource();
}
}
}

@ -11,9 +11,7 @@ namespace Prowlarr.Api.V1.History
public DateTime Date { get; set; }
public string DownloadId { get; set; }
public bool Successful { get; set; }
public HistoryEventType EventType { get; set; }
public Dictionary<string, string> Data { get; set; }
}
@ -29,16 +27,11 @@ namespace Prowlarr.Api.V1.History
return new HistoryResource
{
Id = model.Id,
IndexerId = model.IndexerId,
//QualityCutoffNotMet
Date = model.Date,
DownloadId = model.DownloadId,
Successful = model.Successful,
EventType = model.EventType,
Data = model.Data
};
}

Loading…
Cancel
Save