mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-22 07:42:28 +00:00
Fixed: History being lost per Track on Merge
This commit is contained in:
parent
6060270f14
commit
c39eaabb14
3 changed files with 30 additions and 0 deletions
|
@ -16,6 +16,7 @@ public interface IHistoryRepository : IBasicRepository<History>
|
|||
List<History> FindByDownloadId(string downloadId);
|
||||
List<History> GetByArtist(int artistId, HistoryEventType? eventType);
|
||||
List<History> GetByAlbum(int albumId, HistoryEventType? eventType);
|
||||
List<History> GetByTrack(int trackId, HistoryEventType? eventType);
|
||||
List<History> FindDownloadHistory(int idArtistId, QualityModel quality);
|
||||
void DeleteForArtist(int artistId);
|
||||
void DeleteForAlbum(int albumId);
|
||||
|
@ -83,6 +84,21 @@ public List<History> GetByAlbum(int albumId, HistoryEventType? eventType)
|
|||
return query;
|
||||
}
|
||||
|
||||
public List<History> GetByTrack(int trackId, HistoryEventType? eventType)
|
||||
{
|
||||
var query = Query.Join<History, Track>(JoinType.Inner, h => h.Track, (h, e) => h.TrackId == e.Id)
|
||||
.Where(h => h.TrackId == trackId);
|
||||
|
||||
if (eventType.HasValue)
|
||||
{
|
||||
query.AndWhere(h => h.EventType == eventType);
|
||||
}
|
||||
|
||||
query.OrderByDescending(h => h.Date);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public List<History> FindDownloadHistory(int idArtistId, QualityModel quality)
|
||||
{
|
||||
return Query.Where(h =>
|
||||
|
|
|
@ -24,6 +24,7 @@ public interface IHistoryService
|
|||
History Get(int historyId);
|
||||
List<History> GetByArtist(int artistId, HistoryEventType? eventType);
|
||||
List<History> GetByAlbum(int albumId, HistoryEventType? eventType);
|
||||
List<History> GetByTrack(int trackId, HistoryEventType? eventType);
|
||||
List<History> Find(string downloadId, HistoryEventType eventType);
|
||||
List<History> FindByDownloadId(string downloadId);
|
||||
List<History> Since(DateTime date, HistoryEventType? eventType);
|
||||
|
@ -82,6 +83,11 @@ public List<History> GetByAlbum(int albumId, HistoryEventType? eventType)
|
|||
return _historyRepository.GetByAlbum(albumId, eventType);
|
||||
}
|
||||
|
||||
public List<History> GetByTrack(int trackId, HistoryEventType? eventType)
|
||||
{
|
||||
return _historyRepository.GetByTrack(trackId, eventType);
|
||||
}
|
||||
|
||||
public List<History> Find(string downloadId, HistoryEventType eventType)
|
||||
{
|
||||
return _historyRepository.FindByDownloadId(downloadId).Where(c => c.EventType == eventType).ToList();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NLog;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -15,14 +16,17 @@ public class RefreshTrackService : IRefreshTrackService
|
|||
{
|
||||
private readonly ITrackService _trackService;
|
||||
private readonly IAudioTagService _audioTagService;
|
||||
private readonly IHistoryService _historyService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public RefreshTrackService(ITrackService trackService,
|
||||
IAudioTagService audioTagService,
|
||||
IHistoryService historyService,
|
||||
Logger logger)
|
||||
{
|
||||
_trackService = trackService;
|
||||
_audioTagService = audioTagService;
|
||||
_historyService = historyService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -52,6 +56,10 @@ public bool RefreshTrackInfo(List<Track> add, List<Track> update, List<Tuple<Tra
|
|||
mergeTarget.TrackFileId = trackToMerge.TrackFileId;
|
||||
}
|
||||
|
||||
var items = _historyService.GetByTrack(trackToMerge.Id, null);
|
||||
items.ForEach(x => x.TrackId = mergeTarget.Id);
|
||||
_historyService.UpdateMany(items);
|
||||
|
||||
if (!updateList.Contains(mergeTarget))
|
||||
{
|
||||
updateList.Add(mergeTarget);
|
||||
|
|
Loading…
Reference in a new issue