diff --git a/src/NzbDrone.Api/Episodes/EpisodeResource.cs b/src/NzbDrone.Api/Episodes/EpisodeResource.cs
index 3ff489f38..3eb09bbf4 100644
--- a/src/NzbDrone.Api/Episodes/EpisodeResource.cs
+++ b/src/NzbDrone.Api/Episodes/EpisodeResource.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
@@ -30,6 +30,7 @@ namespace NzbDrone.Api.Episodes
public bool UnverifiedSceneNumbering { get; set; }
public string SeriesTitle { get; set; }
public SeriesResource Series { get; set; }
+ public DateTime? LastSearchTime { get; set; }
//Hiding this so people don't think its usable (only used to set the initial state)
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -65,6 +66,7 @@ namespace NzbDrone.Api.Episodes
UnverifiedSceneNumbering = model.UnverifiedSceneNumbering,
SeriesTitle = model.SeriesTitle,
//Series = model.Series.MapToResource(),
+ LastSearchTime = model.LastSearchTime
};
}
diff --git a/src/NzbDrone.Core/Datastore/Migration/130_episode_last_searched_time.cs b/src/NzbDrone.Core/Datastore/Migration/130_episode_last_searched_time.cs
new file mode 100644
index 000000000..5961b9433
--- /dev/null
+++ b/src/NzbDrone.Core/Datastore/Migration/130_episode_last_searched_time.cs
@@ -0,0 +1,14 @@
+using FluentMigrator;
+using NzbDrone.Core.Datastore.Migration.Framework;
+
+namespace NzbDrone.Core.Datastore.Migration
+{
+ [Migration(130)]
+ public class episode_last_searched_time : NzbDroneMigrationBase
+ {
+ protected override void MainDbUpgrade()
+ {
+ Alter.Table("Episodes").AddColumn("LastSearchTime").AsDateTime().Nullable();
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs
index 5762c3c6a..d589dd9bf 100644
--- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs
+++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
@@ -314,6 +314,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 episodes if at least 1 indexer was searched.
+ if (indexers.Any())
+ {
+ var lastSearchTime = DateTime.UtcNow;
+ _logger.Debug("Setting last search time to: {0}", lastSearchTime);
+
+ criteriaBase.Episodes.ForEach(e => e.LastSearchTime = lastSearchTime);
+ _episodeService.UpdateEpisodes(criteriaBase.Episodes);
+ }
+
return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList();
}
}
diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj
index b7451a357..e92508e37 100644
--- a/src/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/src/NzbDrone.Core/NzbDrone.Core.csproj
@@ -143,6 +143,7 @@
+
diff --git a/src/NzbDrone.Core/Tv/Episode.cs b/src/NzbDrone.Core/Tv/Episode.cs
index dcb95069e..6b34e65fe 100644
--- a/src/NzbDrone.Core/Tv/Episode.cs
+++ b/src/NzbDrone.Core/Tv/Episode.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using Marr.Data;
using NzbDrone.Common.Extensions;
@@ -32,6 +32,7 @@ namespace NzbDrone.Core.Tv
public bool UnverifiedSceneNumbering { get; set; }
public Ratings Ratings { get; set; }
public List Images { get; set; }
+ public DateTime? LastSearchTime { get; set; }
public string SeriesTitle { get; private set; }
@@ -46,4 +47,4 @@ namespace NzbDrone.Core.Tv
return string.Format("[{0}]{1}", Id, Title.NullSafe());
}
}
-}
\ No newline at end of file
+}