feat(admin): 补全平台任务观测 + 空间管理 + 基建加 MinIO/实时探针
对照已实现系统功能补 admin 缺失模块(feat/site): - 全平台任务/运行观测:GET /admin/tasks(跨租户查 sundynix_task,join 租户名/提交人邮箱/评测, 按状态/租户筛 + 状态计数;含 HITL 待审批=筛 waiting)+ TasksPage(状态卡+筛+表)。 - 空间(Space)管理:GET /admin/spaces(跨租户列 Space + 成员数子查询 + kind/归档态)+ SpacesPage。 - 基建观测:infra 加 MinIO(126 对象存储);postgres/redis/minio 从启动标志升级为实时 ping (blob.Ping/Postgres.Ping/Redis.Ping),能反映中途掉线。StatusPage 加 minio 标签、6 个依赖。 - 模型健康/熔断:确认 DashboardPage 已有「运行时链路态」渲染 m.health,无需重做。 验证:admin tsc + vitest 41 过、gateway build/vet/test 过;两新页浏览器实测渲染+优雅错误处理; 两新端点起临时 gateway 打真 PG 实测——tasks(counts+3路join)、spaces(成员数子查询)均返真数据。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 全平台空间观测(管理端「空间管理」页)。系统级口径:跨租户看所有 Space,
|
||||
// 走 WithoutTenant 旁路租户插件。
|
||||
|
||||
// AdminSpaceRow 是管理端空间一行:空间 + 租户名 + 建者邮箱 + 成员数。
|
||||
type AdminSpaceRow struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
TenantName string `json:"tenant_name"`
|
||||
Name string `json:"name"`
|
||||
Kind string `json:"kind"` // personal / project / tenant
|
||||
Creator string `json:"creator"`
|
||||
CreatorEmail string `json:"creator_email"`
|
||||
Archived bool `json:"archived"`
|
||||
Members int64 `json:"members"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// AllSpaces 全平台空间流(管理端观测;跨租户)。倒序,翻页。
|
||||
func (p *Postgres) AllSpaces(ctx context.Context, limit int) []AdminSpaceRow {
|
||||
if p.db == nil {
|
||||
return nil
|
||||
}
|
||||
if limit <= 0 || limit > 500 {
|
||||
limit = 200
|
||||
}
|
||||
ctx = WithoutTenant(ctx) // 系统级:看所有租户的空间
|
||||
var out []AdminSpaceRow
|
||||
p.db.WithContext(ctx).Table("sundynix_space as s").
|
||||
Select("s.id, s.tenant_id, s.name, s.kind, s.creator, s.archived, s.created_at, " +
|
||||
"coalesce(tn.name,'') as tenant_name, coalesce(u.email,'') as creator_email, " +
|
||||
"(select count(*) from sundynix_space_member m where m.space_id = s.id and m.deleted_at is null) as members").
|
||||
Joins("left join sundynix_tenant tn on tn.id = s.tenant_id").
|
||||
Joins("left join sundynix_user u on u.id = s.creator").
|
||||
Where("s.deleted_at is null").
|
||||
Order("s.created_at desc").Limit(limit).Scan(&out)
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user