mirror of https://github.com/lidarr/Lidarr
New: Store last search time for AlbumSearch
(cherry picked from commit 9af57c6786
)
This commit is contained in:
parent
0bcbf9df81
commit
5d8f9c9e27
|
@ -0,0 +1,14 @@
|
|||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(077)]
|
||||
public class album_last_searched_time : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("Albums").AddColumn("LastSearchTime").AsDateTimeOffset().Nullable();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -139,6 +139,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.Albums.ForEach(a => a.LastSearchTime = lastSearchTime);
|
||||
_albumService.UpdateLastSearchTime(criteriaBase.Albums);
|
||||
}
|
||||
|
||||
return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace NzbDrone.Core.Music
|
|||
public string AlbumType { get; set; }
|
||||
public List<SecondaryAlbumType> SecondaryTypes { get; set; }
|
||||
public Ratings Ratings { get; set; }
|
||||
public DateTime? LastSearchTime { get; set; }
|
||||
|
||||
// These are Lidarr generated/config
|
||||
public string CleanTitle { get; set; }
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace NzbDrone.Core.Music
|
|||
Album UpdateAlbum(Album album);
|
||||
void SetAlbumMonitored(int albumId, bool monitored);
|
||||
void SetMonitored(IEnumerable<int> ids, bool monitored);
|
||||
void UpdateLastSearchTime(List<Album> albums);
|
||||
PagingSpec<Album> AlbumsWithoutFiles(PagingSpec<Album> pagingSpec);
|
||||
List<Album> AlbumsBetweenDates(DateTime start, DateTime end, bool includeUnmonitored);
|
||||
List<Album> ArtistAlbumsBetweenDates(Artist artist, DateTime start, DateTime end, bool includeUnmonitored);
|
||||
|
@ -301,6 +302,11 @@ namespace NzbDrone.Core.Music
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateLastSearchTime(List<Album> albums)
|
||||
{
|
||||
_albumRepository.SetFields(albums, a => a.LastSearchTime);
|
||||
}
|
||||
|
||||
public void Handle(ArtistsDeletedEvent message)
|
||||
{
|
||||
// TODO Do this in one call instead of one for each artist?
|
||||
|
|
Loading…
Reference in New Issue