Moved episodeCount logic to mediaFileProvider.

Episode count counts by 5 now, so it doesn't take forever.
pull/6/head
Mark McDowall 14 years ago
parent eb3875d43b
commit 90d9e7d41e

@ -168,8 +168,6 @@ namespace NzbDrone.Core.Providers
} }
} }
public virtual void Update(EpisodeFile episodeFile) public virtual void Update(EpisodeFile episodeFile)
{ {
_repository.Update(episodeFile); _repository.Update(episodeFile);
@ -195,6 +193,17 @@ namespace NzbDrone.Core.Providers
return _seriesProvider.GetSeries(seriesId).Episodes.Where(c => c.EpisodeFile != null).Select(c => c.EpisodeFile); return _seriesProvider.GetSeries(seriesId).Episodes.Where(c => c.EpisodeFile != null).Select(c => c.EpisodeFile);
} }
public virtual Tuple<int, int> GetEpisodeFilesCount(int seriesId)
{
var series = _seriesProvider.GetSeries(seriesId);
var monitoredSeasons = series.Seasons.Where(e => e.Monitored).Select(e => e.SeasonId);
var episodeTotal = series.Episodes.Where(e => monitoredSeasons.Contains(e.SeasonId) && e.AirDate <= DateTime.Today && e.AirDate > new DateTime(1899, 12, 31));
var episodes = episodeTotal.Where(e => e.EpisodeFileId > 0);
return new Tuple<int, int>(episodeTotal.Count(), episodes.Count());
}
private List<string> GetMediaFileList(string path) private List<string> GetMediaFileList(string path)
{ {
Logger.Debug("Scanning '{0}' for episodes", path); Logger.Debug("Scanning '{0}' for episodes", path);

@ -21,6 +21,7 @@ namespace NzbDrone.Web.Controllers
private readonly TvDbProvider _tvDbProvider; private readonly TvDbProvider _tvDbProvider;
private readonly JobProvider _jobProvider; private readonly JobProvider _jobProvider;
private readonly SeasonProvider _seasonProvider; private readonly SeasonProvider _seasonProvider;
private readonly MediaFileProvider _mediaFileProvider;
// //
// GET: /Series/ // GET: /Series/
@ -30,7 +31,8 @@ namespace NzbDrone.Web.Controllers
RenameProvider renameProvider, RenameProvider renameProvider,
TvDbProvider tvDbProvider, TvDbProvider tvDbProvider,
JobProvider jobProvider, JobProvider jobProvider,
SeasonProvider seasonProvider) SeasonProvider seasonProvider,
MediaFileProvider mediaFileProvider)
{ {
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
@ -39,6 +41,7 @@ namespace NzbDrone.Web.Controllers
_tvDbProvider = tvDbProvider; _tvDbProvider = tvDbProvider;
_jobProvider = jobProvider; _jobProvider = jobProvider;
_seasonProvider = seasonProvider; _seasonProvider = seasonProvider;
_mediaFileProvider = mediaFileProvider;
} }
public ActionResult Index() public ActionResult Index()
@ -135,16 +138,12 @@ namespace NzbDrone.Web.Controllers
public JsonResult GetEpisodeCount(int seriesId) public JsonResult GetEpisodeCount(int seriesId)
{ {
var series = _seriesProvider.GetSeries(seriesId); var count = _mediaFileProvider.GetEpisodeFilesCount(seriesId);
var monitoredSeasons = series.Seasons.Where(e => e.Monitored).Select(e => e.SeasonId);
var episodeTotal = series.Episodes.Where(e => monitoredSeasons.Contains(e.SeasonId) && e.AirDate <= DateTime.Today && e.AirDate > new DateTime(1899, 12, 31));
var episodes = episodeTotal.Where(e => e.EpisodeFileId > 0);
return Json(new return Json(new
{ {
Episodes = episodes.Count(), Episodes = count.Item1,
EpisodeTotal = episodeTotal.Count() EpisodeTotal = count.Item2
}, JsonRequestBehavior.AllowGet); }, JsonRequestBehavior.AllowGet);
} }

@ -673,6 +673,7 @@
<Content Include="Scripts\2011.1.315\telerik.treeview.min.js" /> <Content Include="Scripts\2011.1.315\telerik.treeview.min.js" />
<Content Include="Scripts\2011.1.315\telerik.upload.min.js" /> <Content Include="Scripts\2011.1.315\telerik.upload.min.js" />
<Content Include="Scripts\2011.1.315\telerik.window.min.js" /> <Content Include="Scripts\2011.1.315\telerik.window.min.js" />
<Content Include="Scripts\doTimeout.js" />
<Content Include="Scripts\episodeSearch.js" /> <Content Include="Scripts\episodeSearch.js" />
<Content Include="Scripts\gridLoad.js" /> <Content Include="Scripts\gridLoad.js" />
<Content Include="Scripts\jquery-1.6.1-vsdoc.js" /> <Content Include="Scripts\jquery-1.6.1-vsdoc.js" />

@ -169,7 +169,22 @@
success: function (data, textStatus, jqXHR) { success: function (data, textStatus, jqXHR) {
var episodes = data.Episodes; var episodes = data.Episodes;
var episodeTotal = data.EpisodeTotal; var episodeTotal = data.EpisodeTotal;
var counter = 0;
var max = episodes + 1;
$.doTimeout(10, function () {
if (counter >= max) {
$("#progressbar_" + seriesId).episodeProgress(episodes, episodeTotal); $("#progressbar_" + seriesId).episodeProgress(episodes, episodeTotal);
return false;
}
$("#progressbar_" + seriesId).episodeProgress(counter, episodeTotal);
counter += 5;
return true;
});
} }
}); });
} }

@ -102,24 +102,35 @@
</div> </div>
</div> </div>
<div id="progressbar2" class="progressbar">
<div class="progressText"></div>
<div class="progress">
<span class="progressText" style="width: 125px;"></span>
</div>
</div>
<script> <script>
$(document).ready(function () { $(document).ready(function() {
i = 0; progress(65, 100, 'progressbar');
max = 50; progress(22, 25, 'progressbar2');
});
function progress(episodes, episodeTotal, elementName) {
var counter = 0;
var max = episodes + 1;
$.doTimeout(20, function () { $.doTimeout(20, function () {
if (i == max + 1) { if (counter == max) {
return false; return false;
} }
$("#progressbar").episodeProgress(i, 100); $("#" + elementName).episodeProgress(counter, episodeTotal);
i++; counter++;
return true; return true;
}); });
};
//$("#progressbar").episodeProgress(50, 100);
});
</script> </script>
Loading…
Cancel
Save