refactor: address code review findings across all projects
Apply comprehensive fixes from code reviews including: - Extract shared utilities (SqlFormatHelper, CellValueConverter, DbDestinationBase) - Add interface abstractions (IAuthenticationService, IDatabaseMigrator, IMisQueryBuilder) - Implement SecureStore for encrypted secrets storage - Fix error handling with proper HTTP status codes and logging - Optimize double enumeration in DevEtlRegistry - Add DataSync.Dev README for developer onboarding - Extract filter panel base classes to reduce duplication - Update code review docs to mark all issues as fixed
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using JdeScoping.Core.ViewModels;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JdeScoping.Api.Hubs;
|
||||
@@ -9,17 +10,17 @@ namespace JdeScoping.Api.Hubs;
|
||||
/// </summary>
|
||||
public class StatusHub : Hub
|
||||
{
|
||||
private static StatusUpdateViewModel _cachedStatus = new()
|
||||
{
|
||||
Message = "Unknown",
|
||||
Timestamp = DateTime.UtcNow
|
||||
};
|
||||
private const string StatusCacheKey = "StatusHub_CachedStatus";
|
||||
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly ILogger<StatusHub> _logger;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public StatusHub(ILogger<StatusHub> logger)
|
||||
public StatusHub(IMemoryCache cache, ILogger<StatusHub> logger, TimeProvider timeProvider)
|
||||
{
|
||||
_cache = cache;
|
||||
_logger = logger;
|
||||
_timeProvider = timeProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +30,7 @@ public class StatusHub : Hub
|
||||
/// <param name="statusUpdate">Status update to broadcast</param>
|
||||
public async Task SetStatus(StatusUpdateViewModel statusUpdate)
|
||||
{
|
||||
_cachedStatus = statusUpdate;
|
||||
_cache.Set(StatusCacheKey, statusUpdate);
|
||||
await Clients.All.SendAsync("statusUpdate", statusUpdate);
|
||||
_logger.LogDebug("Status updated: {Message}", statusUpdate.Message);
|
||||
}
|
||||
@@ -40,7 +41,11 @@ public class StatusHub : Hub
|
||||
/// <returns>The most recent status update</returns>
|
||||
public StatusUpdateViewModel GetCachedStatus()
|
||||
{
|
||||
return _cachedStatus;
|
||||
return _cache.GetOrCreate(StatusCacheKey, _ => new StatusUpdateViewModel
|
||||
{
|
||||
Message = "Unknown",
|
||||
Timestamp = _timeProvider.GetUtcNow().DateTime
|
||||
})!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user