store scene name in history

pull/3113/head
kay.one 11 years ago
parent b8bd2bffbf
commit e256271c5c

@ -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");
}
}
}

@ -62,7 +62,7 @@ namespace NzbDrone.Core.History
{ {
var history = new History var history = new History
{ {
EventType = HistoryEventType.Grabbed, EventType = HistoryEventType.Grabbed,
Date = DateTime.UtcNow, Date = DateTime.UtcNow,
Quality = message.Episode.ParsedEpisodeInfo.Quality, Quality = message.Episode.ParsedEpisodeInfo.Quality,
SourceTitle = message.Episode.Report.Title, SourceTitle = message.Episode.Report.Title,
@ -81,20 +81,21 @@ namespace NzbDrone.Core.History
public void Handle(EpisodeImportedEvent message) public void Handle(EpisodeImportedEvent message)
{ {
foreach (var episode in message.EpisodeFile.Episodes.Value) foreach (var episode in message.DroppedEpisode.Episodes)
{ {
var history = new History var history = new History
{ {
EventType = HistoryEventType.DownloadFolderImported, EventType = HistoryEventType.DownloadFolderImported,
Date = DateTime.UtcNow, Date = DateTime.UtcNow,
Quality = message.EpisodeFile.Quality, Quality = message.DroppedEpisode.Quality,
SourceTitle = message.EpisodeFile.Path, SourceTitle = message.ImportedEpisode.SceneName,
SeriesId = message.EpisodeFile.SeriesId, SeriesId = message.ImportedEpisode.SeriesId,
EpisodeId = episode.Id EpisodeId = episode.Id
}; };
history.Data.Add("Path", message.EpisodeFile.Path); history.Data.Add("FileId", message.ImportedEpisode.Id.ToString());
history.Data.Add("Filename", Path.GetFileNameWithoutExtension(message.EpisodeFile.Path)); history.Data.Add("DroppedPath", message.DroppedEpisode.Path);
history.Data.Add("ImportedPath", message.ImportedEpisode.Path);
_historyRepository.Insert(history); _historyRepository.Insert(history);
} }

@ -65,12 +65,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath()); episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath());
episodeFile.Episodes = localEpisode.Episodes; episodeFile.Episodes = localEpisode.Episodes;
if (newDownload) if (newDownload)
{ {
episodeFile = _episodeFileUpgrader.UpgradeEpisodeFile(episodeFile, localEpisode); episodeFile = _episodeFileUpgrader.UpgradeEpisodeFile(episodeFile, localEpisode);
_messageAggregator.PublishEvent(new EpisodeImportedEvent(episodeFile)); _messageAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile));
} }
_mediaFileService.Add(episodeFile); _mediaFileService.Add(episodeFile);
imported.Add(importDecision); imported.Add(importDecision);
} }

@ -1,14 +1,17 @@
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.Events namespace NzbDrone.Core.MediaFiles.Events
{ {
public class EpisodeImportedEvent : IEvent 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;
} }
} }
} }

@ -158,6 +158,7 @@
<Compile Include="Datastore\Migration\013_add_air_date_utc.cs" /> <Compile Include="Datastore\Migration\013_add_air_date_utc.cs" />
<Compile Include="Datastore\Migration\014_drop_air_date.cs" /> <Compile Include="Datastore\Migration\014_drop_air_date.cs" />
<Compile Include="Datastore\Migration\015_add_air_date_as_string.cs" /> <Compile Include="Datastore\Migration\015_add_air_date_as_string.cs" />
<Compile Include="Datastore\Migration\016_updated_imported_history_item.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />

@ -35,14 +35,14 @@
{{#if data}} {{#if data}}
{{#with data}} {{#with data}}
<dl class="dl-horizontal"> <dl class="dl-horizontal">
{{#if filename}} {{#if droppedPath}}
<dt>Filename</dt> <dt>Source:</dt>
<dd>{{filename}}</dd> <dd>{{droppedPath}}</dd>
{{/if}} {{/if}}
{{#if path}} {{#if importedPath}}
<dt>Path</dt> <dt>Imported To:</dt>
<dd>{{path}}</dd> <dd>{{importedPath}}</dd>
{{/if}} {{/if}}
</dl> </dl>
{{/with}} {{/with}}

Loading…
Cancel
Save