mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Fixed: History Repo GetById not always ordered by Date
This commit is contained in:
parent
415c2821c8
commit
975d31178b
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
@ -57,5 +59,58 @@ public void should_get_download_history()
|
||||
|
||||
downloadHistory.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_movie_history()
|
||||
{
|
||||
var historyMovie1 = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 12)
|
||||
.With(c => c.EventType = HistoryEventType.Grabbed)
|
||||
.BuildNew();
|
||||
|
||||
var historyMovie2 = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 13)
|
||||
.With(c => c.EventType = HistoryEventType.Grabbed)
|
||||
.BuildNew();
|
||||
|
||||
Subject.Insert(historyMovie1);
|
||||
Subject.Insert(historyMovie2);
|
||||
|
||||
var movieHistory = Subject.GetByMovieId(12, null);
|
||||
|
||||
movieHistory.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_sort_movie_history_by_date()
|
||||
{
|
||||
var historyFirst = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 12)
|
||||
.With(c => c.EventType = HistoryEventType.MovieFileRenamed)
|
||||
.With(c => c.Date = DateTime.UtcNow)
|
||||
.BuildNew();
|
||||
|
||||
var historySecond = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 12)
|
||||
.With(c => c.EventType = HistoryEventType.Grabbed)
|
||||
.With(c => c.Date = DateTime.UtcNow.AddMinutes(10))
|
||||
.BuildNew();
|
||||
|
||||
Subject.Insert(historyFirst);
|
||||
Subject.Insert(historySecond);
|
||||
|
||||
var movieHistory = Subject.GetByMovieId(12, null);
|
||||
|
||||
movieHistory.Should().HaveCount(2);
|
||||
movieHistory.First().EventType.Should().Be(HistoryEventType.Grabbed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,9 +66,7 @@ public List<History> GetByMovieId(int movieId, HistoryEventType? eventType)
|
||||
query = query.Where(h => h.EventType == eventType).ToList();
|
||||
}
|
||||
|
||||
query.OrderByDescending(h => h.Date);
|
||||
|
||||
return query;
|
||||
return query.OrderByDescending(h => h.Date).ToList();
|
||||
}
|
||||
|
||||
public void DeleteForMovie(int movieId)
|
||||
|
Loading…
Reference in New Issue
Block a user