mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
added log trim command
This commit is contained in:
parent
279f8b5d73
commit
73f3459264
16 changed files with 62 additions and 69 deletions
8
NzbDrone.Core/Instrumentation/Commands/TrimLogCommand.cs
Normal file
8
NzbDrone.Core/Instrumentation/Commands/TrimLogCommand.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation.Commands
|
||||
{
|
||||
public class TrimLogCommand : ICommand
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
|
@ -20,8 +18,8 @@ namespace NzbDrone.Core.Instrumentation
|
|||
|
||||
public void Trim()
|
||||
{
|
||||
var oldIds = Query.Where(c => c.Time < DateTime.UtcNow.AddDays(-30).Date).Select(c => c.Id);
|
||||
DeleteMany(oldIds);
|
||||
var trimDate = DateTime.UtcNow.AddDays(-15).Date;
|
||||
Delete(c => c.Time <= trimDate);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,15 @@
|
|||
using System.Linq;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation.Commands;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
public interface ILogService
|
||||
{
|
||||
void DeleteAll();
|
||||
void Trim();
|
||||
PagingSpec<Log> Paged(PagingSpec<Log> pagingSpec);
|
||||
}
|
||||
|
||||
public class LogService : ILogService
|
||||
public class LogService : ILogService, IExecute<TrimLogCommand>
|
||||
{
|
||||
private readonly ILogRepository _logRepository;
|
||||
|
||||
|
@ -19,19 +18,14 @@ namespace NzbDrone.Core.Instrumentation
|
|||
_logRepository = logRepository;
|
||||
}
|
||||
|
||||
public void DeleteAll()
|
||||
{
|
||||
_logRepository.Purge();
|
||||
}
|
||||
|
||||
public void Trim()
|
||||
{
|
||||
_logRepository.Trim();
|
||||
}
|
||||
|
||||
public PagingSpec<Log> Paged(PagingSpec<Log> pagingSpec)
|
||||
{
|
||||
return _logRepository.GetPaged(pagingSpec);
|
||||
}
|
||||
|
||||
public void Execute(TrimLogCommand message)
|
||||
{
|
||||
_logRepository.Trim();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue