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

pull/4/head
Mark McDowall 11 years ago
parent c81c8fec27
commit bb87d4e96e

@ -282,5 +282,29 @@ namespace NzbDrone.Core.Test.TvTests
_updatedEpisodes.First().EpisodeNumber.Should().Be(episodes[1].EpisodeNumber); _updatedEpisodes.First().EpisodeNumber.Should().Be(episodes[1].EpisodeNumber);
_updatedEpisodes.First().AbsoluteEpisodeNumber.Should().Be(episodes[1].AbsoluteEpisodeNumber); _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);
}
} }
} }

@ -170,7 +170,11 @@ namespace NzbDrone.Core.Tv
episode.AbsoluteEpisodeNumber = tvdbEpisode.AbsoluteEpisodeNumber; 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) private Episode GetEpisodeToUpdate(Series series, Episode episode, List<Episode> existingEpisodes)

Loading…
Cancel
Save