feat(admin): plan statistics + node restart/close-ae actions
Build backend images / build content-svc (push) Failing after 1m22s
Build backend images / build file-svc (push) Failing after 3m8s
Build backend images / build gateway (push) Failing after 53s
Build backend images / build identity-svc (push) Failing after 57s
Build backend images / build notification-svc (push) Failing after 1m25s
Build backend images / build render-svc (push) Failing after 2m5s
Build backend images / build studio-svc (push) Failing after 3m59s

Final legacy-admin items:
- identity GET /v1/admin/plan-statistics (active/total users + revenue per plan
  from user_plans); surfaced as a breakdown table in /admin/stats
- NodesTable: wire Restart + Close-AE actions (backend already supported them) via
  new proxy routes; was only drain/release before

Full DivineGateWeb legacy-admin parity achieved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-02 23:02:03 +03:30
parent 3091911260
commit 151970accd
9 changed files with 89 additions and 3 deletions
@@ -57,6 +57,23 @@ public class AdminService(IdentityDbContext db)
pays.Sum(p => p.AmountMinor), payingAllTime, daily);
}
// ── Plan statistics ──────────────────────────────────────────────────────
public async Task<List<PlanStatRow>> GetPlanStatisticsAsync(Guid tenantId)
{
var now = DateTime.UtcNow;
return await db.UserPlans
.Where(p => p.TenantId == tenantId)
.GroupBy(p => p.PlanName)
.Select(g => new PlanStatRow(
g.Key,
g.Count(),
g.Count(x => x.ExpiresAt > now && x.CancelledAt == null),
g.Sum(x => x.PriceMinorPaid)))
.OrderByDescending(r => r.RevenueMinor)
.ToListAsync();
}
// ── CRM notes / tags ────────────────────────────────────────────────────
public async Task<UserCrmResponse> GetUserCrmAsync(Guid userId)
@@ -22,6 +22,10 @@ public class AdminController(AdminService svc) : ControllerBase
return Ok(await svc.GetCrmAnalyticsAsync(TenantId, s, e));
}
// ── Plan statistics ──────────────────────────────────────────────────────
[HttpGet("v1/admin/plan-statistics")]
public async Task<IActionResult> PlanStats() => Ok(await svc.GetPlanStatisticsAsync(TenantId));
// ── CRM notes / tags ───────────────────────────────────────────────────────
[HttpGet("v1/users/{userId:guid}/crm")]
public async Task<IActionResult> GetCrm(Guid userId) => Ok(await svc.GetUserCrmAsync(userId));
@@ -14,6 +14,10 @@ public record CrmAnalyticsResponse(
List<CrmDailyPoint> Daily
);
// ── Plan statistics breakdown ────────────────────────────────────────────────
public record PlanStatRow(string PlanName, int Total, int Active, long RevenueMinor);
// ── CRM notes / tags per customer ────────────────────────────────────────────
public record UserCrmResponse(string[] Tags, string? Note, string Status);