2013-06-05 00:49:53 +00:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
|
|
|
|
using NzbDrone.Api.Mapping;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Logs
|
|
|
|
|
{
|
|
|
|
|
public class LogModule : NzbDroneRestModule<LogResource>
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogService _logService;
|
|
|
|
|
|
|
|
|
|
public LogModule(ILogService logService)
|
|
|
|
|
{
|
|
|
|
|
_logService = logService;
|
|
|
|
|
GetResourcePaged = GetLogs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PagingResource<LogResource> GetLogs(PagingResource<LogResource> pagingResource)
|
|
|
|
|
{
|
|
|
|
|
var pageSpec = pagingResource.InjectTo<PagingSpec<Log>>();
|
2013-09-16 00:48:39 +00:00
|
|
|
|
|
|
|
|
|
if (pageSpec.SortKey == "time")
|
|
|
|
|
{
|
|
|
|
|
pageSpec.SortKey = "id";
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-05 00:49:53 +00:00
|
|
|
|
return ApplyToPage(_logService.Paged, pageSpec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|