Moved episodeCount logic to mediaFileProvider.

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

@ -168,8 +168,6 @@ namespace NzbDrone.Core.Providers
}
}
public virtual void Update(EpisodeFile 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);
}
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)
{
Logger.Debug("Scanning '{0}' for episodes", path);

@ -21,6 +21,7 @@ namespace NzbDrone.Web.Controllers
private readonly TvDbProvider _tvDbProvider;
private readonly JobProvider _jobProvider;
private readonly SeasonProvider _seasonProvider;
private readonly MediaFileProvider _mediaFileProvider;
//
// GET: /Series/
@ -29,8 +30,9 @@ namespace NzbDrone.Web.Controllers
QualityProvider qualityProvider,
RenameProvider renameProvider,
TvDbProvider tvDbProvider,
JobProvider jobProvider,
SeasonProvider seasonProvider)
JobProvider jobProvider,
SeasonProvider seasonProvider,
MediaFileProvider mediaFileProvider)
{
_seriesProvider = seriesProvider;
_episodeProvider = episodeProvider;
@ -39,6 +41,7 @@ namespace NzbDrone.Web.Controllers
_tvDbProvider = tvDbProvider;
_jobProvider = jobProvider;
_seasonProvider = seasonProvider;
_mediaFileProvider = mediaFileProvider;
}
public ActionResult Index()
@ -135,16 +138,12 @@ namespace NzbDrone.Web.Controllers
public JsonResult GetEpisodeCount(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);
var count = _mediaFileProvider.GetEpisodeFilesCount(seriesId);
return Json(new
{
Episodes = episodes.Count(),
EpisodeTotal = episodeTotal.Count()
Episodes = count.Item1,
EpisodeTotal = count.Item2
}, JsonRequestBehavior.AllowGet);
}

@ -673,6 +673,7 @@
<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.window.min.js" />
<Content Include="Scripts\doTimeout.js" />
<Content Include="Scripts\episodeSearch.js" />
<Content Include="Scripts\gridLoad.js" />
<Content Include="Scripts\jquery-1.6.1-vsdoc.js" />

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

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