Added cleanup job for search history

New: Search History cleanup job will only keep the last week of results
This commit is contained in:
Mark McDowall 2012-06-12 12:38:38 -07:00
commit b7408b726a
5 changed files with 159 additions and 0 deletions

View file

@ -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);
}
}
}
}