Harden production schema fallback and profile/dashboard UI
This commit is contained in:
@@ -78,9 +78,56 @@ public sealed class AdminSystemController : ControllerBase
|
||||
var dbPath = _paths.GetDbPath();
|
||||
var dbFile = new FileInfo(dbPath);
|
||||
|
||||
var jobs = await _db.JobApplications.AsNoTracking().ToListAsync(cancellationToken);
|
||||
var companies = await _db.Companies.AsNoTracking().CountAsync(cancellationToken);
|
||||
var ai = await _summarizer.GetMetricsAsync(cancellationToken);
|
||||
var jobCount = 0;
|
||||
var deletedCount = 0;
|
||||
var companies = 0;
|
||||
string? statusWarning = null;
|
||||
try
|
||||
{
|
||||
jobCount = await _db.JobApplications.AsNoTracking().CountAsync(cancellationToken);
|
||||
deletedCount = await _db.JobApplications.AsNoTracking().CountAsync(x => x.IsDeleted, cancellationToken);
|
||||
companies = await _db.Companies.AsNoTracking().CountAsync(cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
statusWarning = $"Data query failed: {ex.GetType().Name}";
|
||||
}
|
||||
|
||||
AiServiceMetrics ai;
|
||||
try
|
||||
{
|
||||
ai = await _summarizer.GetMetricsAsync(cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ai = new AiServiceMetrics(
|
||||
Healthy: false,
|
||||
Model: null,
|
||||
Device: null,
|
||||
GpuAvailable: false,
|
||||
GpuName: null,
|
||||
OcrAvailable: false,
|
||||
OcrLanguages: null,
|
||||
HealthLatencyMs: null,
|
||||
ProbeLatencyMs: null,
|
||||
LastProbeAt: null,
|
||||
LastProbeSuccessAt: null,
|
||||
LastProbeFailureAt: null,
|
||||
ProbeFailures: 0,
|
||||
Requests: 0,
|
||||
CacheHits: 0,
|
||||
CacheMisses: 0,
|
||||
Failures: 0,
|
||||
AverageLatencyMs: null,
|
||||
OcrRequests: 0,
|
||||
OcrFailures: 0,
|
||||
AverageOcrLatencyMs: null,
|
||||
LastOcrSuccessAt: null,
|
||||
LastOcrFailureAt: null,
|
||||
LastSuccessAt: null,
|
||||
LastFailureAt: null,
|
||||
LastError: ex.Message);
|
||||
}
|
||||
|
||||
var version = NormalizeBuildMetadata(_cfg["App:Version"]);
|
||||
if (string.IsNullOrWhiteSpace(version))
|
||||
@@ -130,11 +177,18 @@ public sealed class AdminSystemController : ControllerBase
|
||||
{
|
||||
dbWarning = "Database connection failed.";
|
||||
}
|
||||
else if (!usesFileStorage && jobs.Count == 0 && companies == 0)
|
||||
else if (!usesFileStorage && jobCount == 0 && companies == 0)
|
||||
{
|
||||
dbWarning = "Connected, but no data is present yet. Check whether this is the intended production database.";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(statusWarning))
|
||||
{
|
||||
dbWarning = string.IsNullOrWhiteSpace(dbWarning)
|
||||
? statusWarning
|
||||
: $"{dbWarning} {statusWarning}";
|
||||
}
|
||||
|
||||
var gmailConfigured = !string.IsNullOrWhiteSpace((_cfg["Google:GmailClientSecret"] ?? string.Empty).Trim())
|
||||
&& !string.IsNullOrWhiteSpace((_cfg["Google:GmailRedirectUri"] ?? string.Empty).Trim());
|
||||
|
||||
@@ -150,8 +204,8 @@ public sealed class AdminSystemController : ControllerBase
|
||||
DbExists: dbFile.Exists,
|
||||
DbSizeBytes: dbFile.Exists ? dbFile.Length : null,
|
||||
CompanyCount: companies,
|
||||
JobCount: jobs.Count,
|
||||
DeletedCount: jobs.Count(x => x.IsDeleted)
|
||||
JobCount: jobCount,
|
||||
DeletedCount: deletedCount
|
||||
),
|
||||
Email: new EmailStatusDto(
|
||||
Enabled: _cfg.GetValue("Email:Enabled", false),
|
||||
|
||||
Reference in New Issue
Block a user