Migrate GetAppMetrics, GetGlobalAppMetrics, TenantOffboard refinements

https://claude.ai/code/session_01NHWJfPaa8TQHuPzMD7gG63
This commit is contained in:
Claude
2026-03-27 06:37:11 +00:00
parent d89e2a2ad1
commit cae99b445f
3 changed files with 13 additions and 13 deletions
@@ -37,7 +37,7 @@ public class TenantOffboardFunction
_logger = logger;
_tenantAdminsService = tenantAdminsService;
_globalAdminService = globalAdminService;
_storageService = storageService;
_maintenanceRepo = maintenanceRepo;
var connectionString = configuration["AzureTableStorageConnectionString"];
_tableServiceClient = new TableServiceClient(connectionString);
}
@@ -83,7 +83,7 @@ public class TenantOffboardFunction
_logger.LogWarning($"TENANT OFFBOARD initiated for tenant {tenantId} by {upn}");
// Audit under Global TenantId so the entry survives tenant data deletion
await _storageService.LogAuditEntryAsync(
await _maintenanceRepo.LogAuditEntryAsync(
Constants.AuditGlobalTenantId,
"DELETE",
"Tenant",
@@ -150,7 +150,7 @@ public class TenantOffboardFunction
details["Action"] = "Offboard";
details["Phase"] = "Completed";
details["TotalRowsDeleted"] = result.DeletedCounts.Values.Sum().ToString();
await _storageService.LogAuditEntryAsync(
await _maintenanceRepo.LogAuditEntryAsync(
Constants.AuditGlobalTenantId,
"DELETE",
"Tenant",
@@ -1,6 +1,6 @@
using System.Net;
using AutopilotMonitor.Functions.Helpers;
using AutopilotMonitor.Functions.Services;
using AutopilotMonitor.Shared.DataAccess;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
@@ -10,12 +10,12 @@ namespace AutopilotMonitor.Functions.Functions.Metrics
public class GetAppMetricsFunction
{
private readonly ILogger<GetAppMetricsFunction> _logger;
private readonly TableStorageService _storageService;
private readonly IMetricsRepository _metricsRepo;
public GetAppMetricsFunction(ILogger<GetAppMetricsFunction> logger, TableStorageService storageService)
public GetAppMetricsFunction(ILogger<GetAppMetricsFunction> logger, IMetricsRepository metricsRepo)
{
_logger = logger;
_storageService = storageService;
_metricsRepo = metricsRepo;
}
[Function("GetAppMetrics")]
@@ -37,7 +37,7 @@ namespace AutopilotMonitor.Functions.Functions.Metrics
var cutoff = DateTime.UtcNow.AddDays(-days);
var allSummaries = await _storageService.GetAppInstallSummariesByTenantAsync(tenantId);
var allSummaries = await _metricsRepo.GetAppInstallSummariesByTenantAsync(tenantId);
var summaries = allSummaries.Where(s => s.StartedAt >= cutoff).ToList();
// Aggregate: slowest apps (avg duration) and top failing apps
@@ -1,6 +1,6 @@
using System.Net;
using AutopilotMonitor.Functions.Helpers;
using AutopilotMonitor.Functions.Services;
using AutopilotMonitor.Shared.DataAccess;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
@@ -10,14 +10,14 @@ namespace AutopilotMonitor.Functions.Functions.Metrics
public class GetGlobalAppMetricsFunction
{
private readonly ILogger<GetGlobalAppMetricsFunction> _logger;
private readonly TableStorageService _storageService;
private readonly IMetricsRepository _metricsRepo;
public GetGlobalAppMetricsFunction(
ILogger<GetGlobalAppMetricsFunction> logger,
TableStorageService storageService)
IMetricsRepository metricsRepo)
{
_logger = logger;
_storageService = storageService;
_metricsRepo = metricsRepo;
}
[Function("GetGlobalAppMetrics")]
@@ -39,7 +39,7 @@ namespace AutopilotMonitor.Functions.Functions.Metrics
var cutoff = DateTime.UtcNow.AddDays(-days);
var allSummaries = await _storageService.GetAllAppInstallSummariesAsync();
var allSummaries = await _metricsRepo.GetAllAppInstallSummariesAsync();
var summaries = allSummaries.Where(s => s.StartedAt >= cutoff).ToList();
var appGroups = summaries.GroupBy(s => s.AppName).Select(g =>