diff --git a/NzbDrone.Core/Helpers/SortHelper.cs b/NzbDrone.Core/Helpers/SortHelper.cs new file mode 100644 index 000000000..0b71cef62 --- /dev/null +++ b/NzbDrone.Core/Helpers/SortHelper.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Helpers +{ + public class SortHelper + { + public static string SkipArticles(string input) + { + var articles = new List { "The ", "An ", "A " }; + + foreach (string article in articles) + { + if (input.ToLower().StartsWith(article, StringComparison.InvariantCultureIgnoreCase)) + return input.Substring(article.Length).Trim(); + } + + return input; + } + } +} diff --git a/NzbDrone.Core/Instrumentation/LogProvider.cs b/NzbDrone.Core/Instrumentation/LogProvider.cs index 7fbb54ab0..2b36e579b 100644 --- a/NzbDrone.Core/Instrumentation/LogProvider.cs +++ b/NzbDrone.Core/Instrumentation/LogProvider.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using NLog; using PetaPoco; @@ -21,6 +22,20 @@ namespace NzbDrone.Core.Instrumentation return _database.Fetch(); } + public IList TopLogs() + { + var logs = _database.Fetch("SELECT TOP 7500 * FROM Logs ORDER BY Time Desc"); + logs.Add(new Log + { + Time = DateTime.Now.AddYears(-100), + Level = "Info", + Logger = "NzbDrone.Core.Instrumentation.LogProvider", + Message = String.Format("Number of logs currently shown: 7500. More may exist, check 'All' to see everything") + }); + + return logs; + } + public Page GetPagedLogs(int pageNumber, int pageSize) { return _database.Page(pageNumber, pageSize, "SELECT * FROM Logs ORDER BY Time DESC"); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 31b2ec1b2..ef5e2cd8d 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -182,6 +182,7 @@ + diff --git a/NzbDrone.Web/Controllers/LogController.cs b/NzbDrone.Web/Controllers/LogController.cs index aeef79dbd..90d31a021 100644 --- a/NzbDrone.Web/Controllers/LogController.cs +++ b/NzbDrone.Web/Controllers/LogController.cs @@ -2,6 +2,7 @@ using NzbDrone.Core.Instrumentation; using NzbDrone.Web.Models; using Telerik.Web.Mvc; +using System.Linq; namespace NzbDrone.Web.Controllers { @@ -19,15 +20,28 @@ namespace NzbDrone.Web.Controllers return View(); } + public ActionResult All() + { + return View(); + } + public JsonResult Clear() { _logProvider.DeleteAll(); - return Json(new NotificationResult() { Title = "Logs Cleared" }); + return Json(new NotificationResult { Title = "Logs Cleared" }); + } + + [GridAction] + public ActionResult _TopAjaxBinding() + { + var logs = _logProvider.TopLogs(); + + return View(new GridModel(logs)); } [GridAction(EnableCustomBinding = true)] - public ActionResult _AjaxBinding(GridCommand gridCommand) + public ActionResult _AllAjaxBinding(GridCommand gridCommand) { var logs = _logProvider.GetPagedLogs(gridCommand.Page, gridCommand.PageSize); diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 7536f9fbd..3ba502ccf 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Web.Mvc; using MvcMiniProfiler; +using NzbDrone.Core.Helpers; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Jobs; using NzbDrone.Core.Repository; @@ -50,7 +51,7 @@ namespace NzbDrone.Web.Controllers [GridAction] public ActionResult _AjaxSeriesGrid() { - var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount()); + var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount()).OrderBy(o => SortHelper.SkipArticles(o.Title)); return View(new GridModel(series)); } diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 286cda4f6..7aa2e544a 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -355,6 +355,12 @@ + + + + + +