fixed issue with number only series title.

series detail page should load much faster.
pull/4/head
Keivan Beigi 12 years ago
parent 91cef6d662
commit f44ef2ff5e

@ -32,8 +32,6 @@ namespace NzbDrone.Api.Series
UpdateResource = UpdateSeries; UpdateResource = UpdateSeries;
DeleteResource = DeleteSeries; DeleteResource = DeleteSeries;
Get["/{slug}"] = o => GetSeriesBySlug((string)o.slug.ToString());
SharedValidator.RuleFor(s => s.QualityProfileId).ValidId(); SharedValidator.RuleFor(s => s.QualityProfileId).ValidId();
SharedValidator.RuleFor(s => s.Path).NotEmpty().When(s => String.IsNullOrEmpty(s.RootFolderPath)); SharedValidator.RuleFor(s => s.Path).NotEmpty().When(s => String.IsNullOrEmpty(s.RootFolderPath));
SharedValidator.RuleFor(s => s.RootFolderPath).NotEmpty().When(s => String.IsNullOrEmpty(s.Path)); SharedValidator.RuleFor(s => s.RootFolderPath).NotEmpty().When(s => String.IsNullOrEmpty(s.Path));
@ -43,17 +41,7 @@ namespace NzbDrone.Api.Series
private SeriesResource GetSeries(int id) private SeriesResource GetSeries(int id)
{ {
Core.Tv.Series series = null; var series = _seriesService.GetSeries(id);
try
{
series = _seriesService.GetSeries(id);
}
catch (ModelNotFoundException)
{
series = _seriesService.FindBySlug(id.ToString());
}
return GetSeriesResource(series); return GetSeriesResource(series);
} }

@ -44,7 +44,6 @@ namespace NzbDrone.Integration.Test
Series.All().Should().HaveCount(1); Series.All().Should().HaveCount(1);
Series.Get(series.Id).Should().NotBeNull(); Series.Get(series.Id).Should().NotBeNull();
Series.Get(series.TitleSlug).Should().NotBeNull();
Series.Delete(series.Id); Series.Delete(series.Id);
@ -53,9 +52,9 @@ namespace NzbDrone.Integration.Test
[Test] [Test]
public void should_be_able_to_add_and_get_number_only_series_title() public void should_be_able_to_find_series_by_id()
{ {
var series = Series.Lookup("90210").First(c=>c.TitleSlug == "90210"); var series = Series.Lookup("90210").First();
series.QualityProfileId = 1; series.QualityProfileId = 1;
series.Path = @"C:\Test\90210"; series.Path = @"C:\Test\90210";
@ -65,14 +64,8 @@ namespace NzbDrone.Integration.Test
Series.All().Should().HaveCount(1); Series.All().Should().HaveCount(1);
Series.Get(series.Id).Should().NotBeNull(); Series.Get(series.Id).Should().NotBeNull();
Series.Get(series.TitleSlug).Should().NotBeNull();
} }
[Test]
public void wrong_slug_should_return_404()
{
Series.Get("non-existing-slug", HttpStatusCode.NotFound);
}
[Test] [Test]
public void invalid_id_should_return_404() public void invalid_id_should_return_404()

@ -8,6 +8,7 @@ define(
'AddSeries/AddSeriesLayout', 'AddSeries/AddSeriesLayout',
'Series/Index/SeriesIndexLayout', 'Series/Index/SeriesIndexLayout',
'Series/Details/SeriesDetailsLayout', 'Series/Details/SeriesDetailsLayout',
'Series/SeriesCollection',
'Missing/MissingLayout', 'Missing/MissingLayout',
'Series/SeriesModel', 'Series/SeriesModel',
'Calendar/CalendarLayout', 'Calendar/CalendarLayout',
@ -17,7 +18,7 @@ define(
'System/Layout', 'System/Layout',
'Shared/NotFoundView', 'Shared/NotFoundView',
'Shared/Modal/Region' 'Shared/Modal/Region'
], function (App, Marionette, HistoryLayout, SettingsLayout, AddSeriesLayout, SeriesIndexLayout, SeriesDetailsLayout, MissingLayout, SeriesModel, CalendarLayout, ], function (App, Marionette, HistoryLayout, SettingsLayout, AddSeriesLayout, SeriesIndexLayout, SeriesDetailsLayout,SeriesCollection, MissingLayout, SeriesModel, CalendarLayout,
LogsLayout, LogFileLayout, ReleaseLayout, SystemLayout, NotFoundView) { LogsLayout, LogFileLayout, ReleaseLayout, SystemLayout, NotFoundView) {
return Marionette.Controller.extend({ return Marionette.Controller.extend({
@ -28,15 +29,13 @@ define(
seriesDetails: function (query) { seriesDetails: function (query) {
var self = this; var series = SeriesCollection.where({titleSlug : query});
this._setTitle('Loading Series');
var series = new SeriesModel({ id: query }); if(series.length != 0){
series.fetch({ var targetSeries = series[0];
success: function (seriesModel) { this._setTitle(targetSeries.get('title'));
self._setTitle(seriesModel.get('title')); App.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries }));
App.mainRegion.show(new SeriesDetailsLayout({ model: seriesModel })); }
}
});
}, },
addSeries: function (action) { addSeries: function (action) {

Loading…
Cancel
Save