store scene name in history

This commit is contained in:
kay.one 2013-08-29 23:38:55 -07:00
parent b8bd2bffbf
commit e256271c5c
6 changed files with 39 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -158,6 +158,7 @@
<Compile Include="Datastore\Migration\013_add_air_date_utc.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\016_updated_imported_history_item.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />

View File

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