mirror of
https://github.com/Readarr/Readarr
synced 2026-01-09 00:53:34 +01:00
New: Store last search time for BookSearch
(cherry picked from commit 9af57c6786eedd9beda4e1c6b8cdca20d165b622)
This commit is contained in:
parent
d72c27ceed
commit
c7ee278ee4
4 changed files with 31 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ public Book()
|
|||
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 @@ public interface IBookService
|
|||
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 @@ public void SetMonitored(IEnumerable<int> ids, bool monitored)
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ private async Task<List<DownloadDecision>> Dispatch(Func<IIndexer, Task<IList<Re
|
|||
|
||||
_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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue