mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-23 22:45:06 -04:00
New: Show previously installed version in Updates UI
Co-Authored-By: Taloth <Taloth@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Update;
|
||||
using NzbDrone.Core.Update.History;
|
||||
using Prowlarr.Http;
|
||||
|
||||
namespace Prowlarr.Api.V1.Update
|
||||
@@ -11,10 +13,12 @@ namespace Prowlarr.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 Prowlarr.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;
|
||||
|
||||
Reference in New Issue
Block a user