Added misnamed provider, PLINQ speeds it up, but still to slow for use, paging helps, but isn't consistent.

A bunch of files changed removing System.Linq, thanks Resharper :(
pull/2/head
Mark McDowall 13 years ago
parent 780abad3f7
commit 0b586de226

@ -1231,5 +1231,83 @@ namespace NzbDrone.Core.Test
mocker.VerifyAllMocks();
}
[Test]
public void EpisodesWithFiles_success()
{
var db = MockLib.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(db);
var series = Builder<Series>.CreateNew()
.With(s => s.SeriesId = 10)
.Build();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(c => c.EpisodeFileId = 1)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(2)
.WhereAll()
.Have(c => c.SeriesId = 10)
.Have(c => c.SeasonNumber = 1)
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
.Have(c => c.Ignored = true)
.Have(c => c.EpisodeFile = episodeFile)
.Have(c => c.EpisodeFileId = episodeFile.EpisodeFileId)
.Build().ToList();
db.Insert(series);
db.Insert(episodeFile);
db.InsertMany(episodes);
//Act
var withFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithFiles();
//Assert
withFiles.Should().HaveCount(2);
withFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(0);
withFiles.Where(e => e.EpisodeFile == null).Should().HaveCount(0);
foreach (var withFile in withFiles)
{
withFile.EpisodeFile.Should().NotBeNull();
withFile.SeriesTitle.Should().NotBeNullOrEmpty();
}
mocker.VerifyAllMocks();
}
[Test]
public void EpisodesWithFiles_no_files()
{
var db = MockLib.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(db);
var series = Builder<Series>.CreateNew()
.With(s => s.SeriesId = 10)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(2)
.WhereAll()
.Have(c => c.SeriesId = 10)
.Have(c => c.SeasonNumber = 1)
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
.Have(c => c.Ignored = true)
.Have(c => c.EpisodeFileId = 0)
.Build().ToList();
db.Insert(series);
db.InsertMany(episodes);
//Act
var withFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithFiles();
//Assert
withFiles.Should().HaveCount(0);
mocker.VerifyAllMocks();
}
}
}

@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NzbDrone.Core.Datastore;

@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using AutoMoq;
using FizzWare.NBuilder;

@ -0,0 +1,250 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
{
[TestFixture]
public class MisnamedProviderTest
{
[Test]
public void no_misnamed_files()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(f => f.EpisodeFileId = 1)
.Has(f => f.Path = @"C:\Test\Title1.avi")
.AndTheNext(1)
.Has(f => f.EpisodeFileId = 2)
.Has(f => f.Path = @"C:\Test\Title2.avi")
.Build();
var episodes = Builder<Episode>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(e => e.EpisodeFileId = 1)
.Has(e => e.EpisodeFile = episodeFiles[0])
.Has(e => e.SeriesTitle = "SeriesTitle1")
.AndTheNext(1)
.Has(e => e.EpisodeFileId = 2)
.Has(e => e.EpisodeFile = episodeFiles[1])
.Has(e => e.SeriesTitle = "SeriesTitle2")
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> {episodes[0]}, "SeriesTitle1", It.IsAny<QualityTypes>()))
.Returns("Title1");
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> {episodes[1]}, "SeriesTitle2", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(0);
}
[Test]
public void all_misnamed_files()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(f => f.EpisodeFileId = 1)
.Has(f => f.Path = @"C:\Test\Title1.avi")
.AndTheNext(1)
.Has(f => f.EpisodeFileId = 2)
.Has(f => f.Path = @"C:\Test\Title2.avi")
.Build();
var episodes = Builder<Episode>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(e => e.EpisodeFileId = 1)
.Has(e => e.EpisodeFile = episodeFiles[0])
.Has(e => e.SeriesTitle = "SeriesTitle1")
.AndTheNext(1)
.Has(e => e.EpisodeFileId = 2)
.Has(e => e.EpisodeFile = episodeFiles[1])
.Has(e => e.SeriesTitle = "SeriesTitle2")
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle1", It.IsAny<QualityTypes>()))
.Returns("New Title 1");
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle2", It.IsAny<QualityTypes>()))
.Returns("New Title 2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(2);
}
[Test]
public void one_misnamed_file()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(f => f.EpisodeFileId = 1)
.Has(f => f.Path = @"C:\Test\Title1.avi")
.AndTheNext(1)
.Has(f => f.EpisodeFileId = 2)
.Has(f => f.Path = @"C:\Test\Title2.avi")
.Build();
var episodes = Builder<Episode>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(e => e.EpisodeFileId = 1)
.Has(e => e.EpisodeFile = episodeFiles[0])
.Has(e => e.SeriesTitle = "SeriesTitle1")
.AndTheNext(1)
.Has(e => e.EpisodeFileId = 2)
.Has(e => e.EpisodeFile = episodeFiles[1])
.Has(e => e.SeriesTitle = "SeriesTitle2")
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle1", It.IsAny<QualityTypes>()))
.Returns("New Title 1");
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle2", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(1);
misnamedEpisodes[0].CurrentName.Should().Be("Title1");
misnamedEpisodes[0].ProperName.Should().Be("New Title 1");
}
[Test]
public void misnamed_multi_episode_file()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(f => f.EpisodeFileId = 1)
.Has(f => f.Path = @"C:\Test\Title1.avi")
.AndTheNext(1)
.Has(f => f.EpisodeFileId = 2)
.Has(f => f.Path = @"C:\Test\Title2.avi")
.Build();
var episodes = Builder<Episode>.CreateListOfSize(3)
.WhereTheFirst(2)
.Has(e => e.EpisodeFileId = 1)
.Has(e => e.EpisodeFile = episodeFiles[0])
.Has(e => e.SeriesTitle = "SeriesTitle1")
.AndTheNext(1)
.Has(e => e.EpisodeFileId = 2)
.Has(e => e.EpisodeFile = episodeFiles[1])
.Has(e => e.SeriesTitle = "SeriesTitle2")
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle1", It.IsAny<QualityTypes>()))
.Returns("New Title 1");
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle2", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(1);
misnamedEpisodes[0].CurrentName.Should().Be("Title1");
misnamedEpisodes[0].ProperName.Should().Be("New Title 1");
}
[Test]
public void no_misnamed_multi_episode_file()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.WhereTheFirst(1)
.Has(f => f.EpisodeFileId = 1)
.Has(f => f.Path = @"C:\Test\Title1.avi")
.AndTheNext(1)
.Has(f => f.EpisodeFileId = 2)
.Has(f => f.Path = @"C:\Test\Title2.avi")
.Build();
var episodes = Builder<Episode>.CreateListOfSize(3)
.WhereTheFirst(2)
.Has(e => e.EpisodeFileId = 1)
.Has(e => e.EpisodeFile = episodeFiles[0])
.Has(e => e.SeriesTitle = "SeriesTitle1")
.AndTheNext(1)
.Has(e => e.EpisodeFileId = 2)
.Has(e => e.EpisodeFile = episodeFiles[1])
.Has(e => e.SeriesTitle = "SeriesTitle2")
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle1", It.IsAny<QualityTypes>()))
.Returns("Title1");
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle2", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(0);
}
}
}

@ -89,6 +89,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BacklogSearchJobTest.cs" />
<Compile Include="MisnamedProviderTest.cs" />
<Compile Include="SeasonSearchJobTest.cs" />
<Compile Include="SearchProviderTest_PartialSeason.cs" />
<Compile Include="SearchJobTest.cs" />

@ -1,7 +1,6 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMoq;
using Moq;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlServerCe;
using System.Linq;
using System.Text;
using MvcMiniProfiler.Data;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace NzbDrone.Core.Model
{
public class MisnamedEpisodeModel
{
public int EpisodeFileId { get; set; }
public int SeriesId { get; set; }
public string SeriesTitle { get; set; }
public string CurrentName { get; set; }
public string ProperName { get; set; }
}
}

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Search

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Search

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Xbmc

@ -182,6 +182,7 @@
<Compile Include="Fluent.cs" />
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
<Compile Include="Helpers\FileSizeFormatHelpercs.cs" />
<Compile Include="Helpers\LinqPageExtension.cs" />
<Compile Include="Instrumentation\LogProvider.cs" />
<Compile Include="Instrumentation\DatabaseTarget.cs" />
<Compile Include="Instrumentation\ExceptioneerTarget.cs" />
@ -191,6 +192,7 @@
<Compile Include="Model\ExternalNotificationType.cs" />
<Compile Include="Model\JobQueueItem.cs" />
<Compile Include="Model\LanguageType.cs" />
<Compile Include="Model\MisnamedEpisodeModel.cs" />
<Compile Include="Model\Quality.cs" />
<Compile Include="Model\SabnzbdCategoryModel.cs" />
<Compile Include="Model\SabnzbdInfoModel.cs" />
@ -206,6 +208,7 @@
<Compile Include="Providers\Jobs\SeriesSearchJob.cs" />
<Compile Include="Providers\Jobs\RenameSeasonJob.cs" />
<Compile Include="Providers\Jobs\SeasonSearchJob.cs" />
<Compile Include="Providers\MisnamedProvider.cs" />
<Compile Include="Providers\SearchProvider.cs" />
<Compile Include="Providers\Xbmc\ResourceManager.cs" />
<Compile Include="Model\Xbmc\TvShowResult.cs" />

@ -1,7 +1,7 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace NzbDrone.Core.Providers.Core
{

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;

@ -175,6 +175,15 @@ namespace NzbDrone.Core.Providers
return AttachSeries(_database.Fetch<Episode>("WHERE EpisodeFileId = @0", episodeFileId));
}
public virtual IList<Episode> EpisodesWithFiles()
{
var episodes = _database.Fetch<Episode, EpisodeFile>(@"SELECT Episodes.*, Series.Title as SeriesTitle, EpisodeFiles.* FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
INNER JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId");
return episodes;
}
public virtual void RefreshEpisodeInfo(Series series)
{
Logger.Info("Starting episode info refresh for series: {0}", series.Title.WithDefault(series.SeriesId));

@ -1,6 +1,6 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using Ninject;
using NzbDrone.Core.Model;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Diagnostics;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
public class MisnamedProvider
{
private readonly MediaFileProvider _mediaFileProvider;
private readonly EpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public MisnamedProvider(MediaFileProvider mediaFileProvider, EpisodeProvider episodeProvider)
{
_mediaFileProvider = mediaFileProvider;
_episodeProvider = episodeProvider;
}
public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int pageSize, out int totalItems)
{
var misnamedFiles = new List<MisnamedEpisodeModel>();
var episodesWithFiles = _episodeProvider.EpisodesWithFiles().GroupBy(e => e.EpisodeFileId).ToList();
totalItems = episodesWithFiles.Count();
var stopwatch = new Stopwatch();
stopwatch.Start();
var misnamedFilesSelect = episodesWithFiles.AsParallel().Where(
w =>
w.First().EpisodeFile.Path !=
_mediaFileProvider.GetNewFilename(w.Select(e => e).ToList(), w.First().SeriesTitle,
w.First().EpisodeFile.Quality)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
//Process the episodes
misnamedFilesSelect.AsParallel().ForAll(f =>
{
var episodes = f.Select(e => e).ToList();
var firstEpisode = episodes[0];
var properName = _mediaFileProvider.GetNewFilename(episodes,
firstEpisode.SeriesTitle,
firstEpisode.EpisodeFile.Quality);
var currentName = Path.GetFileNameWithoutExtension(firstEpisode.EpisodeFile.Path);
if (properName != currentName)
{
misnamedFiles.Add(new MisnamedEpisodeModel
{
CurrentName = currentName,
EpisodeFileId = firstEpisode.EpisodeFileId,
ProperName = properName,
SeriesId = firstEpisode.SeriesId,
SeriesTitle = firstEpisode.SeriesTitle
});
}
});
stopwatch.Stop();
return misnamedFiles.OrderBy(e => e.SeriesTitle).ToList();
}
}
}

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using NzbDrone.Core.Providers.Core;

@ -59,6 +59,9 @@ namespace NzbDrone.Core.Repository
[ResultColumn]
public EpisodeFile EpisodeFile { get; set; }
[ResultColumn]
public string SeriesTitle { get; set; }
public override string ToString()
{
string seriesTitle = Series == null ? "[NULL]" : Series.Title;

@ -1,8 +1,8 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using PetaPoco;
namespace NzbDrone.Core.Repository.Quality

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Web.Mvc;
using System.Linq;
using System.Web.Mvc;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
using NzbDrone.Web.Models;
using Telerik.Web.Mvc;
namespace NzbDrone.Web.Controllers
{
public class MisnamedController : Controller
{
private readonly MisnamedProvider _misnamedProvider;
public MisnamedController(MisnamedProvider misnamedProvider)
{
_misnamedProvider = misnamedProvider;
}
public ActionResult Index()
{
return View();
}
[GridAction(EnableCustomBinding = true)]
public ActionResult _AjaxBinding(GridCommand gridCommand)
{
var totalItems = 0;
var misnamed = _misnamedProvider.MisnamedFiles(gridCommand.Page, gridCommand.PageSize, out totalItems);
return View(new GridModel{ Data = misnamed, Total = totalItems });
}
}
}

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

@ -1,7 +1,7 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;

@ -1,6 +1,6 @@
using System;
using System.Linq;
using System.Data.Common;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Web;

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository.Quality;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;

@ -154,6 +154,7 @@
<Compile Include="Controllers\HistoryController.cs" />
<Compile Include="Controllers\LogController.cs" />
<Compile Include="Controllers\AddSeriesController.cs" />
<Compile Include="Controllers\MisnamedController.cs" />
<Compile Include="Controllers\MissingController.cs" />
<Compile Include="Controllers\NotificationController.cs" />
<Compile Include="Controllers\SeriesController.cs" />
@ -351,6 +352,9 @@
<Content Include="Views\Settings\Test.cshtml" />
<Content Include="Views\Settings\TestPartial.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Misnamed\Index.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -0,0 +1,97 @@
@using NzbDrone.Core.Model
@section TitleContent{
Misnamed
}
@section ActionMenu{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Trim History", "Trim", "History", new AjaxOptions{ OnSuccess = "reloadHistoryGrid" })</li>
<li>@Ajax.ActionLink("Purge History", "Purge", "History", new AjaxOptions { OnSuccess = "reloadHistoryGrid"})</li>
</ul>
}
<style>
.searchImage
{
width: 18px;
height: 18px;
padding: 1px;
margin: 2px;
@*border-width: 1px;
border-style: dashed;
border-color: lightgray;*@
}
.searchImage:hover
{
background-color: #065EFE;
}
</style>
@section MainContent{
<div class="grid-container">
@{Html.Telerik().Grid<MisnamedEpisodeModel>().Name("misnamed")
.TableHtmlAttributes(new { @class = "Grid" })
.Columns(columns =>
{
columns.Bound(c => c.SeriesTitle)
.ClientTemplate("<a href=" +
Url.Action("Details", "Series", new { seriesId = "<#= SeriesId #>" }) +
"><#= SeriesTitle #></a>")
.Title("Series Title");
columns.Bound(c => c.CurrentName).Title("Current Name");
columns.Bound(c => c.ProperName).Title("Proper Name");
columns.Bound(c => c.EpisodeFileId)
.Title("Actions")
.Width("40");
})
.DataBinding(data => data.Ajax().Select("_AjaxBinding", "Misnamed"))
.Pageable(
c =>
c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious))
.EnableCustomBinding(true)
.ClientEvents(clientEvents =>
{
clientEvents.OnDataBound("grid_dataBound");
})
.Render();}
</div>
}
<script type="text/javascript">
deleteHistoryRowUrl = '../History/Delete';
redownloadUrl = '../History/Redownload';
function reloadHistoryGrid() {
var grid = $('#history').data('tGrid');
grid.rebind();
grid.sort("Date-desc");
}
function deleteHistoryRow(historyId) {
$.ajax({
type: "POST",
url: deleteHistoryRowUrl,
data: jQuery.param({ historyId: historyId }),
success: function () {
reloadHistoryGrid();
}
});
}
function redownload(historyId, episodeId) {
$.ajax({
type: "POST",
url: redownloadUrl,
data: jQuery.param({ historyId: historyId, episodeId: episodeId }),
success: function () {
reloadHistoryGrid();
}
});
}
function grid_dataBound(e) {
var id = $(this).attr('id');
var lastButton = $('#' + id + ' .t-arrow-last');
lastButton.hide();
}
</script>
Loading…
Cancel
Save