mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
moved history over to objectdb
This commit is contained in:
parent
cf8be4bf8f
commit
f568fdad6a
20 changed files with 259 additions and 494 deletions
41
NzbDrone.Core/History/HistoryRepository.cs
Normal file
41
NzbDrone.Core/History/HistoryRepository.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.History
|
||||
{
|
||||
public interface IHistoryRepository : IBasicRepository<History>
|
||||
{
|
||||
void Trim();
|
||||
QualityModel GetBestQualityInHistory(int seriesId, int seasonNumber, int episodeNumber);
|
||||
}
|
||||
|
||||
public class HistoryRepository : BasicRepository<History>, IHistoryRepository
|
||||
{
|
||||
public HistoryRepository(IObjectDatabase objectDatabase)
|
||||
: base(objectDatabase)
|
||||
{
|
||||
}
|
||||
|
||||
public void Trim()
|
||||
{
|
||||
var oldIds = Queryable.Where(c => c.Date < DateTime.Now.AddDays(-30).Date).Select(c => c.OID);
|
||||
DeleteMany(oldIds);
|
||||
}
|
||||
|
||||
|
||||
public QualityModel GetBestQualityInHistory(int seriesId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
var history = Queryable.OrderByDescending(c => c.Quality).FirstOrDefault(c => c.Episode.Series.SeriesId == seriesId && c.Episode.SeasonNumber == seasonNumber &&
|
||||
c.Episode.EpisodeNumber == episodeNumber);
|
||||
|
||||
if (history != null)
|
||||
{
|
||||
return history.Quality;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue