fixed issue with number only series title.

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

@ -32,8 +32,6 @@ namespace NzbDrone.Api.Series
UpdateResource = UpdateSeries;
DeleteResource = DeleteSeries;
Get["/{slug}"] = o => GetSeriesBySlug((string)o.slug.ToString());
SharedValidator.RuleFor(s => s.QualityProfileId).ValidId();
SharedValidator.RuleFor(s => s.Path).NotEmpty().When(s => String.IsNullOrEmpty(s.RootFolderPath));
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)
{
Core.Tv.Series series = null;
try
{
series = _seriesService.GetSeries(id);
}
catch (ModelNotFoundException)
{
series = _seriesService.FindBySlug(id.ToString());
}
var series = _seriesService.GetSeries(id);
return GetSeriesResource(series);
}
@ -109,7 +97,7 @@ namespace NzbDrone.Api.Series
{
var deleteFiles = false;
var deleteFilesQuery = Request.Query.deleteFiles;
if (deleteFilesQuery.HasValue)
{
deleteFiles = Convert.ToBoolean(deleteFilesQuery.Value);

@ -44,7 +44,6 @@ namespace NzbDrone.Integration.Test
Series.All().Should().HaveCount(1);
Series.Get(series.Id).Should().NotBeNull();
Series.Get(series.TitleSlug).Should().NotBeNull();
Series.Delete(series.Id);
@ -53,9 +52,9 @@ namespace NzbDrone.Integration.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.Path = @"C:\Test\90210";
@ -65,14 +64,8 @@ namespace NzbDrone.Integration.Test
Series.All().Should().HaveCount(1);
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]
public void invalid_id_should_return_404()

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

Loading…
Cancel
Save