diff --git a/src/NzbDrone.Core/Books/Model/Book.cs b/src/NzbDrone.Core/Books/Model/Book.cs index 0cd369f71..8c05c2d68 100644 --- a/src/NzbDrone.Core/Books/Model/Book.cs +++ b/src/NzbDrone.Core/Books/Model/Book.cs @@ -34,6 +34,7 @@ public Book() public List Genres { get; set; } public List RelatedBooks { get; set; } public Ratings Ratings { get; set; } + public DateTime? LastSearchTime { get; set; } // These are Readarr generated/config public string CleanTitle { get; set; } diff --git a/src/NzbDrone.Core/Books/Services/BookService.cs b/src/NzbDrone.Core/Books/Services/BookService.cs index 3a0946aef..d68384340 100644 --- a/src/NzbDrone.Core/Books/Services/BookService.cs +++ b/src/NzbDrone.Core/Books/Services/BookService.cs @@ -31,6 +31,7 @@ public interface IBookService Book UpdateBook(Book book); void SetBookMonitored(int bookId, bool monitored); void SetMonitored(IEnumerable ids, bool monitored); + void UpdateLastSearchTime(List books); PagingSpec BooksWithoutFiles(PagingSpec pagingSpec); List BooksBetweenDates(DateTime start, DateTime end, bool includeUnmonitored); List AuthorBooksBetweenDates(Author author, DateTime start, DateTime end, bool includeUnmonitored); @@ -303,6 +304,11 @@ public void SetMonitored(IEnumerable ids, bool monitored) } } + public void UpdateLastSearchTime(List books) + { + _bookRepository.SetFields(books, b => b.LastSearchTime); + } + public void Handle(AuthorDeletedEvent message) { var books = GetBooksByAuthorMetadataId(message.Author.AuthorMetadataId); diff --git a/src/NzbDrone.Core/Datastore/Migration/039_book_last_searched_time.cs b/src/NzbDrone.Core/Datastore/Migration/039_book_last_searched_time.cs new file mode 100644 index 000000000..d8f55f79c --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/039_book_last_searched_time.cs @@ -0,0 +1,14 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(039)] + public class book_last_searched_time : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Books").AddColumn("LastSearchTime").AsDateTimeOffset().Nullable(); + } + } +} diff --git a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs index dc4844bb9..523d661ed 100644 --- a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs @@ -136,6 +136,16 @@ private async Task> Dispatch(Func a.LastSearchTime = lastSearchTime); + _bookService.UpdateLastSearchTime(criteriaBase.Books); + } + return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList(); }