From e256271c5c321cded971867ceb1e467ef43f93f7 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 29 Aug 2013 23:38:55 -0700 Subject: [PATCH] store scene name in history --- .../016_updated_imported_history_item.cs | 14 ++++++++++++++ NzbDrone.Core/History/HistoryService.cs | 15 ++++++++------- .../EpisodeImport/ImportApprovedEpisodes.cs | 6 ++++-- .../MediaFiles/Events/EpisodeImportedEvent.cs | 9 ++++++--- NzbDrone.Core/NzbDrone.Core.csproj | 1 + .../Details/HistoryDetailsViewTemplate.html | 12 ++++++------ 6 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs diff --git a/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs b/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs new file mode 100644 index 000000000..7a2c50e71 --- /dev/null +++ b/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs @@ -0,0 +1,14 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(16)] + public class updated_imported_history_item : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.Sql(@"UPDATE HISTORY SET Data = replace( Data, '""Path""', '""ImportedPath""' ) WHERE EventType=3"); + } + } +} diff --git a/NzbDrone.Core/History/HistoryService.cs b/NzbDrone.Core/History/HistoryService.cs index 40f637fcf..349d81c08 100644 --- a/NzbDrone.Core/History/HistoryService.cs +++ b/NzbDrone.Core/History/HistoryService.cs @@ -62,7 +62,7 @@ namespace NzbDrone.Core.History { var history = new History { - EventType = HistoryEventType.Grabbed, + EventType = HistoryEventType.Grabbed, Date = DateTime.UtcNow, Quality = message.Episode.ParsedEpisodeInfo.Quality, SourceTitle = message.Episode.Report.Title, @@ -81,20 +81,21 @@ namespace NzbDrone.Core.History public void Handle(EpisodeImportedEvent message) { - foreach (var episode in message.EpisodeFile.Episodes.Value) + foreach (var episode in message.DroppedEpisode.Episodes) { var history = new History { EventType = HistoryEventType.DownloadFolderImported, Date = DateTime.UtcNow, - Quality = message.EpisodeFile.Quality, - SourceTitle = message.EpisodeFile.Path, - SeriesId = message.EpisodeFile.SeriesId, + Quality = message.DroppedEpisode.Quality, + SourceTitle = message.ImportedEpisode.SceneName, + SeriesId = message.ImportedEpisode.SeriesId, EpisodeId = episode.Id }; - history.Data.Add("Path", message.EpisodeFile.Path); - history.Data.Add("Filename", Path.GetFileNameWithoutExtension(message.EpisodeFile.Path)); + history.Data.Add("FileId", message.ImportedEpisode.Id.ToString()); + history.Data.Add("DroppedPath", message.DroppedEpisode.Path); + history.Data.Add("ImportedPath", message.ImportedEpisode.Path); _historyRepository.Insert(history); } diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs index 0757b1495..539bb8ccd 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs @@ -65,12 +65,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath()); episodeFile.Episodes = localEpisode.Episodes; + if (newDownload) { episodeFile = _episodeFileUpgrader.UpgradeEpisodeFile(episodeFile, localEpisode); - _messageAggregator.PublishEvent(new EpisodeImportedEvent(episodeFile)); + _messageAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile)); } - + + _mediaFileService.Add(episodeFile); imported.Add(importDecision); } diff --git a/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs b/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs index 9c8e59cdc..2f166b069 100644 --- a/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs +++ b/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs @@ -1,14 +1,17 @@ using NzbDrone.Common.Messaging; +using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.MediaFiles.Events { public class EpisodeImportedEvent : IEvent { - public EpisodeFile EpisodeFile { get; private set; } + public LocalEpisode DroppedEpisode { get; private set; } + public EpisodeFile ImportedEpisode { get; private set; } - public EpisodeImportedEvent(EpisodeFile episodeFile) + public EpisodeImportedEvent(LocalEpisode droppedEpisode, EpisodeFile importedEpisode) { - EpisodeFile = episodeFile; + DroppedEpisode = droppedEpisode; + ImportedEpisode = importedEpisode; } } } \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 9ed55a6ff..26f5df9b8 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -158,6 +158,7 @@ + diff --git a/UI/History/Details/HistoryDetailsViewTemplate.html b/UI/History/Details/HistoryDetailsViewTemplate.html index 832573e9e..5d15ca7b4 100644 --- a/UI/History/Details/HistoryDetailsViewTemplate.html +++ b/UI/History/Details/HistoryDetailsViewTemplate.html @@ -35,14 +35,14 @@ {{#if data}} {{#with data}}
- {{#if filename}} -
Filename
-
{{filename}}
+ {{#if droppedPath}} +
Source:
+
{{droppedPath}}
{{/if}} - {{#if path}} -
Path
-
{{path}}
+ {{#if importedPath}} +
Imported To:
+
{{importedPath}}
{{/if}}
{{/with}}