Fixed: Get all anime episodes even when absolute episode number is zero

This commit is contained in:
Mark McDowall 2014-07-13 19:11:28 -07:00
parent c81c8fec27
commit bb87d4e96e
2 changed files with 29 additions and 1 deletions

View File

@ -282,5 +282,29 @@ namespace NzbDrone.Core.Test.TvTests
_updatedEpisodes.First().EpisodeNumber.Should().Be(episodes[1].EpisodeNumber);
_updatedEpisodes.First().AbsoluteEpisodeNumber.Should().Be(episodes[1].AbsoluteEpisodeNumber);
}
[Test]
public void should_ignore_episodes_with_absolute_episode_of_zero_in_distinct_by_absolute()
{
var episodes = Builder<Episode>.CreateListOfSize(10)
.Build()
.ToList();
episodes[0].AbsoluteEpisodeNumber = 0;
episodes[1].AbsoluteEpisodeNumber = 0;
episodes[2].AbsoluteEpisodeNumber = 0;
episodes[3].AbsoluteEpisodeNumber = 0;
episodes[4].AbsoluteEpisodeNumber = 0;
GivenAnimeEpisodes(episodes);
Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<Int32>()))
.Returns(new List<Episode>());
Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes);
_insertedEpisodes.Should().HaveCount(episodes.Count);
}
}
}

View File

@ -170,7 +170,11 @@ namespace NzbDrone.Core.Tv
episode.AbsoluteEpisodeNumber = tvdbEpisode.AbsoluteEpisodeNumber;
}
return traktEpisodes.DistinctBy(e => e.AbsoluteEpisodeNumber).ToList();
//Return all episodes with abs 0, but distinct by abs for ones greater than 0
return traktEpisodes.Where(e => e.AbsoluteEpisodeNumber > 0)
.DistinctBy(e => e.AbsoluteEpisodeNumber)
.Concat(traktEpisodes.Where(e => e.AbsoluteEpisodeNumber == 0))
.ToList();
}
private Episode GetEpisodeToUpdate(Series series, Episode episode, List<Episode> existingEpisodes)