mirror of
https://github.com/fergalmoran/Readarr.git
synced 2025-12-22 09:29:59 +00:00
New: Store last search time for BookSearch
(cherry picked from commit 9af57c6786eedd9beda4e1c6b8cdca20d165b622)
This commit is contained in:
@@ -34,6 +34,7 @@ namespace NzbDrone.Core.Books
|
||||
public List<string> Genres { get; set; }
|
||||
public List<int> RelatedBooks { get; set; }
|
||||
public Ratings Ratings { get; set; }
|
||||
public DateTime? LastSearchTime { get; set; }
|
||||
|
||||
// These are Readarr generated/config
|
||||
public string CleanTitle { get; set; }
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace NzbDrone.Core.Books
|
||||
Book UpdateBook(Book book);
|
||||
void SetBookMonitored(int bookId, bool monitored);
|
||||
void SetMonitored(IEnumerable<int> ids, bool monitored);
|
||||
void UpdateLastSearchTime(List<Book> books);
|
||||
PagingSpec<Book> BooksWithoutFiles(PagingSpec<Book> pagingSpec);
|
||||
List<Book> BooksBetweenDates(DateTime start, DateTime end, bool includeUnmonitored);
|
||||
List<Book> AuthorBooksBetweenDates(Author author, DateTime start, DateTime end, bool includeUnmonitored);
|
||||
@@ -303,6 +304,11 @@ namespace NzbDrone.Core.Books
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLastSearchTime(List<Book> books)
|
||||
{
|
||||
_bookRepository.SetFields(books, b => b.LastSearchTime);
|
||||
}
|
||||
|
||||
public void Handle(AuthorDeletedEvent message)
|
||||
{
|
||||
var books = GetBooksByAuthorMetadataId(message.Author.AuthorMetadataId);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,16 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
|
||||
_logger.Debug("Total of {0} reports were found for {1} from {2} indexers", reports.Count, criteriaBase, indexers.Count);
|
||||
|
||||
// Update the last search time for all albums if at least 1 indexer was searched.
|
||||
if (indexers.Any())
|
||||
{
|
||||
var lastSearchTime = DateTime.UtcNow;
|
||||
_logger.Debug("Setting last search time to: {0}", lastSearchTime);
|
||||
|
||||
criteriaBase.Books.ForEach(a => a.LastSearchTime = lastSearchTime);
|
||||
_bookService.UpdateLastSearchTime(criteriaBase.Books);
|
||||
}
|
||||
|
||||
return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user