mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Added cleanup job for search history
New: Search History cleanup job will only keep the last week of results
This commit is contained in:
parent
c50ed82b7e
commit
b7408b726a
5 changed files with 159 additions and 0 deletions
|
@ -117,5 +117,19 @@ namespace NzbDrone.Core.Providers
|
|||
logger.Info("Forcing Download of: {0}", item.ReportTitle);
|
||||
_downloadProvider.DownloadReport(parseResult);
|
||||
}
|
||||
|
||||
public virtual void Cleanup()
|
||||
{
|
||||
var ids = _database.Fetch<int>("SELECT Id FROM SearchHistory WHERE SearchTime > @0", DateTime.Now.AddDays(7));
|
||||
|
||||
if (ids.Any())
|
||||
{
|
||||
logger.Trace("Deleting old search items");
|
||||
_database.Execute("DELETE FROM SearchHistoryItems WHERE SearchHistoryId IN (@0)", ids);
|
||||
|
||||
logger.Trace("Deleting old search results");
|
||||
_database.Execute("DELETE FROM SearchHistory WHERE Id IN (@0)", ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue