mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
updated history table
This commit is contained in:
parent
8467349305
commit
ca71025bca
@ -3,8 +3,6 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.HistoryTests
|
||||
@ -30,5 +28,18 @@ public void Trim_Items()
|
||||
AllStoredModels.Should().HaveCount(10);
|
||||
AllStoredModels.Should().OnlyContain(s => s.Date > DateTime.Now.AddDays(-30));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_read_write_dictionary()
|
||||
{
|
||||
var history = Builder<History.History>.CreateNew().BuildNew();
|
||||
|
||||
history.Data.Add("key1","value1");
|
||||
history.Data.Add("key2","value2");
|
||||
|
||||
Subject.Insert(history);
|
||||
|
||||
StoredModel.Data.Should().HaveCount(2);
|
||||
}
|
||||
}
|
||||
}
|
@ -34,28 +34,6 @@ public void get_files_by_series()
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void get_files_by_season()
|
||||
{
|
||||
var files = Builder<EpisodeFile>.CreateListOfSize(20)
|
||||
.All()
|
||||
.With(c => c.Id = 0)
|
||||
.With(s => s.SeasonNumber = 10)
|
||||
.TheFirst(10)
|
||||
.With(c => c.SeriesId = 1)
|
||||
.TheNext(10)
|
||||
.With(c => c.SeriesId = 2)
|
||||
.Random(10)
|
||||
.With(s => s.SeasonNumber = 20)
|
||||
.Build();
|
||||
|
||||
|
||||
Db.InsertMany(files);
|
||||
|
||||
|
||||
Subject.GetFilesBySeason(1, 20).Should().OnlyContain(c => c.SeriesId == 1 && c.SeasonNumber == 20);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetFileByPath_should_return_null_if_file_does_not_exist_in_database()
|
||||
|
@ -58,7 +58,7 @@ private void WithRecentFolderWrite()
|
||||
[Test]
|
||||
public void should_import_file()
|
||||
{
|
||||
Subject.ProcessDownloadedEpiosdesFolder();
|
||||
Subject.ProcessDownloadedEpisodesFolder();
|
||||
|
||||
VerifyImport();
|
||||
}
|
||||
@ -68,7 +68,7 @@ public void should_skip_if_folder_is_too_fresh()
|
||||
{
|
||||
WithRecentFolderWrite();
|
||||
|
||||
Subject.ProcessDownloadedEpiosdesFolder();
|
||||
Subject.ProcessDownloadedEpisodesFolder();
|
||||
|
||||
VerifyNoImport();
|
||||
}
|
||||
@ -78,7 +78,7 @@ public void should_search_for_series_using_folder_name()
|
||||
{
|
||||
WithOldWrite();
|
||||
|
||||
Subject.ProcessDownloadedEpiosdesFolder();
|
||||
Subject.ProcessDownloadedEpisodesFolder();
|
||||
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.GetSeries("foldername"), Times.Once());
|
||||
|
||||
@ -90,7 +90,7 @@ public void all_imported_files_should_be_moved()
|
||||
Mocker.GetMock<IDiskScanService>().Setup(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()))
|
||||
.Returns(_fakeEpisodeFile);
|
||||
|
||||
Subject.ProcessDownloadedEpiosdesFolder();
|
||||
Subject.ProcessDownloadedEpisodesFolder();
|
||||
|
||||
Mocker.GetMock<IMoveEpisodeFiles>().Verify(c => c.MoveEpisodeFile(_fakeEpisodeFile, true), Times.Once());
|
||||
}
|
||||
@ -101,7 +101,7 @@ public void should_not_attempt_move_if_nothing_is_imported()
|
||||
Mocker.GetMock<IDiskScanService>().Setup(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()))
|
||||
.Returns<EpisodeFile>(null);
|
||||
|
||||
Subject.ProcessDownloadedEpiosdesFolder();
|
||||
Subject.ProcessDownloadedEpisodesFolder();
|
||||
|
||||
Mocker.GetMock<IMoveEpisodeFiles>().Verify(c => c.MoveEpisodeFile(It.IsAny<EpisodeFile>(), It.IsAny<bool>()), Times.Never());
|
||||
}
|
||||
@ -113,7 +113,7 @@ public void should_skip_if_folder_is_in_use_by_another_process()
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.IsFileLocked(It.IsAny<FileInfo>()))
|
||||
.Returns(true);
|
||||
|
||||
Subject.ProcessDownloadedEpiosdesFolder();
|
||||
Subject.ProcessDownloadedEpisodesFolder();
|
||||
VerifyNoImport();
|
||||
}
|
||||
|
||||
|
24
NzbDrone.Core/Datastore/Migration/004_updated_history.cs
Normal file
24
NzbDrone.Core/Datastore/Migration/004_updated_history.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Tags("")]
|
||||
[Migration(4)]
|
||||
public class updated_history : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Delete.Table("History");
|
||||
|
||||
|
||||
Create.TableForModel("History")
|
||||
.WithColumn("EpisodeId").AsInt32()
|
||||
.WithColumn("SeriesId").AsInt32()
|
||||
.WithColumn("SourceTitle").AsString()
|
||||
.WithColumn("Date").AsDateTime()
|
||||
.WithColumn("Quality").AsString()
|
||||
.WithColumn("Data").AsString();
|
||||
}
|
||||
}
|
||||
}
|
@ -79,6 +79,7 @@ private static void RegisterMappers()
|
||||
MapRepository.Instance.RegisterTypeConverter(typeof(Boolean), new BooleanIntConverter());
|
||||
MapRepository.Instance.RegisterTypeConverter(typeof(Enum), new EnumIntConverter());
|
||||
MapRepository.Instance.RegisterTypeConverter(typeof(Quality), new QualityIntConverter());
|
||||
MapRepository.Instance.RegisterTypeConverter(typeof(Dictionary<string, string>), new EmbeddedDocumentConverter());
|
||||
}
|
||||
|
||||
private static void RegisterEmbeddedConverter()
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Marr.Data;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
@ -8,16 +7,21 @@ namespace NzbDrone.Core.History
|
||||
{
|
||||
public class History : ModelBase
|
||||
{
|
||||
public History()
|
||||
{
|
||||
Data = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public int EpisodeId { get; set; }
|
||||
public int SeriesId { get; set; }
|
||||
public string NzbTitle { get; set; }
|
||||
public string SourceTitle { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public string NzbInfoUrl { get; set; }
|
||||
public string ReleaseGroup { get; set; }
|
||||
|
||||
public Episode Episode { get; set; }
|
||||
public Series Series { get; set; }
|
||||
|
||||
public Dictionary<string, string> Data { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.History
|
||||
@ -18,7 +19,7 @@ public interface IHistoryService
|
||||
PagingSpec<History> Paged(PagingSpec<History> pagingSpec);
|
||||
}
|
||||
|
||||
public class HistoryService : IHistoryService, IHandle<EpisodeGrabbedEvent>
|
||||
public class HistoryService : IHistoryService, IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeImportedEvent>
|
||||
{
|
||||
private readonly IHistoryRepository _historyRepository;
|
||||
private readonly Logger _logger;
|
||||
@ -61,13 +62,32 @@ public void Handle(EpisodeGrabbedEvent message)
|
||||
var history = new History
|
||||
{
|
||||
Date = DateTime.Now,
|
||||
Indexer = message.Episode.Report.Indexer,
|
||||
Quality = message.Episode.ParsedEpisodeInfo.Quality,
|
||||
NzbTitle = message.Episode.Report.Title,
|
||||
SourceTitle = message.Episode.Report.Title,
|
||||
SeriesId = episode.SeriesId,
|
||||
EpisodeId = episode.Id,
|
||||
NzbInfoUrl = message.Episode.Report.NzbInfoUrl,
|
||||
ReleaseGroup = message.Episode.Report.ReleaseGroup,
|
||||
};
|
||||
|
||||
history.Data.Add("Indexer", message.Episode.Report.Indexer);
|
||||
history.Data.Add("NzbInfoUrl", message.Episode.Report.NzbInfoUrl);
|
||||
history.Data.Add("ReleaseGroup", message.Episode.Report.ReleaseGroup);
|
||||
history.Data.Add("Age", message.Episode.Report.Age.ToString());
|
||||
|
||||
_historyRepository.Insert(history);
|
||||
}
|
||||
}
|
||||
|
||||
public void Handle(EpisodeImportedEvent message)
|
||||
{
|
||||
foreach (var episode in message.EpisodeFile.Episodes.Value)
|
||||
{
|
||||
var history = new History
|
||||
{
|
||||
Date = DateTime.Now,
|
||||
Quality = message.EpisodeFile.Quality,
|
||||
SourceTitle = message.EpisodeFile.Path,
|
||||
SeriesId = message.EpisodeFile.SeriesId,
|
||||
EpisodeId = episode.Id,
|
||||
};
|
||||
|
||||
_historyRepository.Insert(history);
|
||||
|
@ -5,6 +5,7 @@
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
@ -18,6 +19,7 @@ public class DownloadedEpisodesImportService : IExecute<DownloadedEpisodesScanCo
|
||||
private readonly IMoveEpisodeFiles _episodeFileMover;
|
||||
private readonly IParsingService _parsingService;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly IMessageAggregator _messageAggregator;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DownloadedEpisodesImportService(IDiskProvider diskProvider,
|
||||
@ -26,6 +28,7 @@ public DownloadedEpisodesImportService(IDiskProvider diskProvider,
|
||||
IMoveEpisodeFiles episodeFileMover,
|
||||
IParsingService parsingService,
|
||||
IConfigService configService,
|
||||
IMessageAggregator messageAggregator,
|
||||
Logger logger)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
@ -34,10 +37,11 @@ public DownloadedEpisodesImportService(IDiskProvider diskProvider,
|
||||
_episodeFileMover = episodeFileMover;
|
||||
_parsingService = parsingService;
|
||||
_configService = configService;
|
||||
_messageAggregator = messageAggregator;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void ProcessDownloadedEpiosdesFolder()
|
||||
public void ProcessDownloadedEpisodesFolder()
|
||||
{
|
||||
//TODO: We should also process the download client's category folder
|
||||
var downloadedEpisodesFolder = _configService.DownloadedEpisodesFolder;
|
||||
@ -135,11 +139,13 @@ public void ProcessVideoFile(string videoFile, Series series)
|
||||
{
|
||||
_episodeFileMover.MoveEpisodeFile(episodeFile, true);
|
||||
}
|
||||
|
||||
_messageAggregator.PublishEvent(new EpisodeImportedEvent(episodeFile));
|
||||
}
|
||||
|
||||
public void Execute(DownloadedEpisodesScanCommand message)
|
||||
{
|
||||
ProcessDownloadedEpiosdesFolder();
|
||||
ProcessDownloadedEpisodesFolder();
|
||||
}
|
||||
}
|
||||
}
|
14
NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs
Normal file
14
NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class EpisodeImportedEvent:IEvent
|
||||
{
|
||||
public EpisodeFile EpisodeFile { get; private set; }
|
||||
|
||||
public EpisodeImportedEvent(EpisodeFile episodeFile)
|
||||
{
|
||||
EpisodeFile = episodeFile;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ public interface IMediaFileRepository : IBasicRepository<EpisodeFile>
|
||||
{
|
||||
EpisodeFile GetFileByPath(string path);
|
||||
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
||||
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
||||
bool Exists(string path);
|
||||
}
|
||||
|
||||
@ -37,10 +36,5 @@ public List<EpisodeFile> GetFilesBySeries(int seriesId)
|
||||
return Query.Where(c => c.SeriesId == seriesId).ToList();
|
||||
}
|
||||
|
||||
public List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
||||
{
|
||||
return Query.Where(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,6 @@ public interface IMediaFileService
|
||||
bool Exists(string path);
|
||||
EpisodeFile GetFileByPath(string path);
|
||||
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
||||
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
||||
}
|
||||
|
||||
public class MediaFileService : IMediaFileService, IHandleAsync<SeriesDeletedEvent>
|
||||
@ -68,11 +67,6 @@ public List<EpisodeFile> GetFilesBySeries(int seriesId)
|
||||
return _mediaFileRepository.GetFilesBySeries(seriesId);
|
||||
}
|
||||
|
||||
public List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
||||
{
|
||||
return _mediaFileRepository.GetFilesBySeason(seriesId, seasonNumber);
|
||||
}
|
||||
|
||||
public void HandleAsync(SeriesDeletedEvent message)
|
||||
{
|
||||
var files = GetFilesBySeries(message.Series.Id);
|
||||
|
@ -209,6 +209,7 @@
|
||||
<Compile Include="Datastore\MappingExtensions.cs" />
|
||||
<Compile Include="Datastore\Migration\002_remove_tvrage_imdb_unique_constraint.cs" />
|
||||
<Compile Include="Datastore\Migration\003_remove_clean_title_from_scene_mapping.cs" />
|
||||
<Compile Include="Datastore\Migration\004_updated_history.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationOptions.cs" />
|
||||
@ -259,6 +260,7 @@
|
||||
<Compile Include="MediaFiles\Commands\CleanUpRecycleBinCommand.cs" />
|
||||
<Compile Include="MediaFiles\Commands\DownloadedEpisodesScanCommand.cs" />
|
||||
<Compile Include="MediaFiles\Commands\DiskScanCommand.cs" />
|
||||
<Compile Include="MediaFiles\Events\EpisodeImportedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\EpisodeDownloadedEvent.cs" />
|
||||
<Compile Include="Download\EpisodeGrabbedEvent.cs" />
|
||||
<Compile Include="Download\SeriesRenamedEvent.cs" />
|
||||
|
34
UI/Shared/Cells/ToggleCell.js
Normal file
34
UI/Shared/Cells/ToggleCell.js
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
define(['app', 'Episode/Layout'], function () {
|
||||
NzbDrone.Series.Details.EpisodeIgnoreCell = Backgrid.Cell.extend({
|
||||
|
||||
className: 'episode-status-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
if (this.model) {
|
||||
|
||||
var icon;
|
||||
|
||||
if (this.model.get('episodeFile')) {
|
||||
icon = 'icon-ok';
|
||||
|
||||
}
|
||||
else {
|
||||
if (this.model.get('hasAired')) {
|
||||
icon = 'icon-warning-sign';
|
||||
}
|
||||
else {
|
||||
icon = 'icon-time';
|
||||
}
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}"/>'.format(icon));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user