New: Basic stats on your library. View at: /System/Stats

pull/6/head
Mark McDowall 12 years ago
parent 05b91dbb4f
commit a1fa6287c7

@ -164,7 +164,6 @@ namespace NzbDrone.Core.Test
[TestCase("Pawn Stars S04E87 REPACK 720p HDTV x264 aAF", QualityTypes.HDTV, true)]
[TestCase("The Real Housewives of Vancouver S01E04 DSR x264 2HD", QualityTypes.SDTV, false)]
[TestCase("Vanguard S01E04 Mexicos Death Train DSR x264 MiNDTHEGAP", QualityTypes.SDTV, false)]
public void quality_parse(string postTitle, object quality, bool proper)
{
var result = Parser.ParseQuality(postTitle);

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
{
public class StatsModel
{
[DisplayName("Number of Series")]
public int SeriesTotal { get; set; }
[DisplayName("Number of Series Countinuing")]
public int SeriesContinuing { get; set; }
[DisplayName("Number of Series Ended")]
public int SeriesEnded { get; set; }
[DisplayName("Number of Episodes")]
public int EpisodesTotal { get; set; }
[DisplayName("Number of Episodes On Disk")]
public int EpisodesOnDisk { get; set; }
[DisplayName("Number of Episodes Missing")]
public int EpisodesMissing { get; set; }
[DisplayName("Downloaded in the Last Week")]
public int DownloadLastWeek { get; set; }
[DisplayName("Downloaded in the Last 30 days")]
public int DownloadedLastMonth { get; set; }
}
}

@ -264,6 +264,7 @@
<Compile Include="Model\Sabnzbd\SabModel.cs" />
<Compile Include="Model\Sabnzbd\SabQueueItem.cs" />
<Compile Include="Model\Sabnzbd\SabVersionModel.cs" />
<Compile Include="Model\StatsModel.cs" />
<Compile Include="Model\Twitter\TwitterAuthorizationModel.cs" />
<Compile Include="Model\UpdatePackage.cs" />
<Compile Include="Model\Xbmc\ActionType.cs" />
@ -305,6 +306,7 @@
<Compile Include="Providers\AnalyticsProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Providers\StatsProvider.cs" />
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
<Compile Include="Repository\Search\SearchHistory.cs" />
<Compile Include="Model\ReportRejectionType.cs" />

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
namespace NzbDrone.Core.Providers
{
public class StatsProvider
{
private readonly IDatabase _database;
[Inject]
public StatsProvider(IDatabase database)
{
_database = database;
}
public StatsProvider()
{
}
public virtual StatsModel GetStats()
{
var series = _database.Fetch<Series>();
var episodes = _database.Fetch<Episode>();
var history = _database.Fetch<History>("WHERE Date <= @0", DateTime.Today.AddDays(-30));
var stats = new StatsModel();
stats.SeriesTotal = series.Count;
stats.SeriesContinuing = series.Count(s => s.Status == "Continuing");
stats.SeriesEnded = series.Count(s => s.Status == "Ended");
stats.EpisodesTotal = episodes.Count;
stats.EpisodesOnDisk = episodes.Count(e => e.EpisodeFileId > 0);
stats.EpisodesMissing = episodes.Count(e => e.Ignored == false && e.EpisodeFileId == 0);
stats.DownloadedLastMonth = history.Count;
stats.DownloadLastWeek = history.Count(h => h.Date <= DateTime.Today.AddDays(7));
return stats;
}
}
}

@ -22,16 +22,18 @@ namespace NzbDrone.Web.Controllers
private readonly ConfigProvider _configProvider;
private readonly DiskProvider _diskProvider;
private readonly BackupProvider _backupProvider;
private readonly StatsProvider _statsProvider;
public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider,
ConfigProvider configProvider, DiskProvider diskProvider,
BackupProvider backupProvider)
BackupProvider backupProvider, StatsProvider statsProvider)
{
_jobProvider = jobProvider;
_indexerProvider = indexerProvider;
_configProvider = configProvider;
_diskProvider = diskProvider;
_backupProvider = backupProvider;
_statsProvider = statsProvider;
}
public ActionResult Jobs()
@ -176,5 +178,12 @@ namespace NzbDrone.Web.Controllers
return File(fileInfo.FullName, "application/binary", fileInfo.Name);
}
public ActionResult Stats()
{
var model = _statsProvider.GetStats();
return View(model);
}
}
}

@ -531,6 +531,9 @@
<ItemGroup>
<Content Include="Views\SearchHistory\Details.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\System\Stats.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

@ -0,0 +1,41 @@
@model NzbDrone.Core.Model.StatsModel
@{
ViewBag.Title = "Stats";
}
@section HeaderContent
{
<style>
label
{
font-weight: bold;
}
</style>
}
<h2>Stats</h2>
@Html.LabelFor(m => m.SeriesTotal):
@Html.DisplayTextFor(m => m.SeriesTotal)
<br/>
@Html.LabelFor(m => m.SeriesContinuing):
@Html.DisplayTextFor(m => m.SeriesContinuing)
<br/>
@Html.LabelFor(m => m.SeriesEnded):
@Html.DisplayTextFor(m => m.SeriesEnded)
<br/>
@Html.LabelFor(m => m.EpisodesTotal):
@Html.DisplayTextFor(m => m.EpisodesTotal)
<br/>
@Html.LabelFor(m => m.EpisodesOnDisk):
@Html.DisplayTextFor(m => m.EpisodesOnDisk)
<br/>
@Html.LabelFor(m => m.EpisodesMissing):
@Html.DisplayTextFor(m => m.EpisodesMissing)
<br/>
@Html.LabelFor(m => m.DownloadLastWeek):
@Html.DisplayTextFor(m => m.DownloadLastWeek)
<br/>
@Html.LabelFor(m => m.DownloadedLastMonth):
@Html.DisplayTextFor(m => m.DownloadedLastMonth)
Loading…
Cancel
Save