feat(ops): add usage_logs partition status to ops dashboard

Add partition management integration to the smart ops system:
- Backend: Add GetUsageLogsPartitionStatus endpoint in OpsHandler
- Backend: Add partition query methods in OpsRepository
- Backend: Add UsageLogsPartitionStatus type in OpsService
- Frontend: Add OpsPartitionStatusCard component
- Frontend: Add partition status display in OpsDashboard
- i18n: Add Chinese and English translations

The partition status card shows:
- Whether usage_logs is partitioned
- Current row count vs threshold (100K)
- Partition count (if partitioned)
- Warning message when partitioning is recommended

This allows administrators to monitor partition status directly
from the ops dashboard without checking server logs.
This commit is contained in:
User
2026-04-16 23:16:17 +08:00
parent eb5adbbae5
commit 60d15d2ba4
10 changed files with 409 additions and 1 deletions

View File

@@ -923,3 +923,22 @@ func parseOpsDuration(v string) (time.Duration, bool) {
return 0, false
}
}
// ==================== Usage Logs Partition Management ====================
// GetUsageLogsPartitionStatus returns partition status of usage_logs table.
// GET /api/v1/admin/ops/partition-status
func (h *OpsHandler) GetUsageLogsPartitionStatus(c *gin.Context) {
if h.opsService == nil {
response.Error(c, http.StatusServiceUnavailable, "Ops service not available")
return
}
status, err := h.opsService.GetUsageLogsPartitionStatus(c.Request.Context())
if err != nil {
response.ErrorFrom(c, err)
return
}
response.Success(c, status)
}