New: Show previously installed version in Updates UI

Co-Authored-By: Taloth <Taloth@users.noreply.github.com>
This commit is contained in:
Qstick 2021-01-24 23:33:54 -05:00
parent 635c3f6853
commit 24e0336f06
18 changed files with 317 additions and 10 deletions

View file

@ -3,7 +3,9 @@ using System.Linq;
using Lidarr.Http;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Update;
using NzbDrone.Core.Update.History;
namespace Lidarr.Api.V1.Update
{
@ -11,10 +13,12 @@ namespace Lidarr.Api.V1.Update
public class UpdateController : Controller
{
private readonly IRecentUpdateProvider _recentUpdateProvider;
private readonly IUpdateHistoryService _updateHistoryService;
public UpdateController(IRecentUpdateProvider recentUpdateProvider)
public UpdateController(IRecentUpdateProvider recentUpdateProvider, IUpdateHistoryService updateHistoryService)
{
_recentUpdateProvider = recentUpdateProvider;
_updateHistoryService = updateHistoryService;
}
[HttpGet]
@ -40,6 +44,18 @@ namespace Lidarr.Api.V1.Update
{
installed.Installed = true;
}
var installDates = _updateHistoryService.InstalledSince(resources.Last().ReleaseDate)
.DistinctBy(v => v.Version)
.ToDictionary(v => v.Version);
foreach (var resource in resources)
{
if (installDates.TryGetValue(resource.Version, out var installDate))
{
resource.InstalledOn = installDate.Date;
}
}
}
return resources;