Added some missing indexes database.

This commit is contained in:
kayone 2013-11-30 13:56:41 -08:00 committed by Mark McDowall
parent 5117eaaf5c
commit c973ab844a
8 changed files with 52 additions and 12 deletions

View File

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.Blacklisting
{ {
Subject.Insert(_blacklist); Subject.Insert(_blacklist);
Subject.Blacklisted(_blacklist.SourceTitle.ToUpperInvariant()).Should().BeTrue(); Subject.Blacklisted(_blacklist.SeriesId, _blacklist.SourceTitle.ToUpperInvariant()).Should().BeTrue();
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace NzbDrone.Core.Blacklisting
{ {
public interface IBlacklistRepository : IBasicRepository<Blacklist> public interface IBlacklistRepository : IBasicRepository<Blacklist>
{ {
bool Blacklisted(string sourceTitle); bool Blacklisted(int seriesId, string sourceTitle);
List<Blacklist> BlacklistedBySeries(int seriesId); List<Blacklist> BlacklistedBySeries(int seriesId);
} }
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Blacklisting
{ {
} }
public bool Blacklisted(string sourceTitle) public bool Blacklisted(int seriesId, string sourceTitle)
{ {
return Query.Where(e => e.SourceTitle.Contains(sourceTitle)).Any(); return Query.Where(e => e.SourceTitle.Contains(sourceTitle)).Any();
} }

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Blacklisting
{ {
public interface IBlacklistService public interface IBlacklistService
{ {
bool Blacklisted(string sourceTitle); bool Blacklisted(int seriesId,string sourceTitle);
PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec); PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec);
void Delete(int id); void Delete(int id);
} }
@ -25,9 +25,9 @@ namespace NzbDrone.Core.Blacklisting
_redownloadFailedDownloadService = redownloadFailedDownloadService; _redownloadFailedDownloadService = redownloadFailedDownloadService;
} }
public bool Blacklisted(string sourceTitle) public bool Blacklisted(int seriesId, string sourceTitle)
{ {
return _blacklistRepository.Blacklisted(sourceTitle); return _blacklistRepository.Blacklisted(seriesId,sourceTitle);
} }
public PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec) public PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec)

View File

@ -0,0 +1,25 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(32)]
public class add_indexes : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Create.Index().OnTable("Blacklist").OnColumn("SeriesId");
Create.Index().OnTable("EpisodeFiles").OnColumn("SeriesId");
Create.Index().OnTable("Episodes").OnColumn("EpisodeFileId");
Create.Index().OnTable("Episodes").OnColumn("SeriesId");
Create.Index().OnTable("History").OnColumn("EpisodeId");
Create.Index().OnTable("Series").OnColumn("Path");
Create.Index().OnTable("Series").OnColumn("CleanTitle");
Create.Index().OnTable("Series").OnColumn("TvRageId");
}
}
}

View File

@ -35,7 +35,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
return true; return true;
} }
if (_blacklistService.Blacklisted(subject.Release.Title)) if (_blacklistService.Blacklisted(subject.Series.Id, subject.Release.Title))
{ {
_logger.Trace("{0} is blacklisted, rejecting.", subject.Release.Title); _logger.Trace("{0} is blacklisted, rejecting.", subject.Release.Title);
return false; return false;

View File

@ -173,6 +173,7 @@
<Compile Include="Datastore\Migration\028_add_blacklist_table.cs" /> <Compile Include="Datastore\Migration\028_add_blacklist_table.cs" />
<Compile Include="Datastore\Migration\029_add_formats_to_naming_config.cs" /> <Compile Include="Datastore\Migration\029_add_formats_to_naming_config.cs" />
<Compile Include="Datastore\Migration\031_delete_old_naming_config_columns.cs" /> <Compile Include="Datastore\Migration\031_delete_old_naming_config_columns.cs" />
<Compile Include="Datastore\Migration\032_add_indexes.cs" />
<Compile Include="Datastore\Migration\030_add_season_folder_format_to_naming_config.cs" /> <Compile Include="Datastore\Migration\030_add_season_folder_format_to_naming_config.cs" />
<Compile Include="Datastore\Migration\032_set_default_release_group.cs" /> <Compile Include="Datastore\Migration\032_set_default_release_group.cs" />
<Compile Include="Datastore\Migration\033_add_api_key_to_pushover.cs" /> <Compile Include="Datastore\Migration\033_add_api_key_to_pushover.cs" />

View File

@ -1,4 +1,5 @@
using System.IO; using System;
using System.IO;
using System.Text; using System.Text;
using NLog; using NLog;
using NzbDrone.Common.Instrumentation; using NzbDrone.Common.Instrumentation;
@ -7,8 +8,12 @@ namespace NzbDrone.Host.Owin
{ {
public class NlogTextWriter : TextWriter public class NlogTextWriter : TextWriter
{ {
private readonly Logger _logger = NzbDroneLogger.GetLogger(); private readonly Logger _logger;
public NlogTextWriter(Logger logger)
{
_logger = logger;
}
public override Encoding Encoding public override Encoding Encoding
{ {
@ -28,9 +33,16 @@ namespace NzbDrone.Host.Owin
} }
public override void Write(string value) public override void Write(string value)
{
if (value.ToLower().Contains("error"))
{
_logger.Error(value);
}
else
{ {
_logger.Trace(value); _logger.Trace(value);
} }
}
public override void Write(char value) public override void Write(char value)
{ {

View File

@ -1,14 +1,16 @@
using System.IO; using System.IO;
using Microsoft.Owin.Hosting.Tracing; using Microsoft.Owin.Hosting.Tracing;
using NLog;
namespace NzbDrone.Host.Owin namespace NzbDrone.Host.Owin
{ {
public class OwinTraceOutputFactory : ITraceOutputFactory public class OwinTraceOutputFactory : ITraceOutputFactory
{ {
private readonly Logger logger = LogManager.GetLogger("Owin");
public TextWriter Create(string outputFile) public TextWriter Create(string outputFile)
{ {
return new NlogTextWriter(); return new NlogTextWriter(logger);
} }
} }
} }