Skip to content

Commit 9dac9c0

Browse files
committed
feat: add usage reset radar
1 parent 28b6f71 commit 9dac9c0

12 files changed

Lines changed: 1794 additions & 2 deletions

File tree

admin/handler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ type Handler struct {
6666
reqCountMu sync.RWMutex
6767
reqCountCache map[int64]*database.AccountRequestCount
6868
reqCountExpiresAt time.Time
69+
70+
resetRadarHookMu sync.Mutex
71+
resetRadarHookState resetRadarHookState
72+
resetRadarHookRunner func(context.Context, string) resetRadarHookResult
6973
}
7074

7175
type chartCacheEntry struct {
@@ -184,6 +188,7 @@ func NewHandler(store *auth.Store, db *database.DB, tc cache.TokenCache, rl *pro
184188
}
185189
handler.refreshAccount = handler.refreshSingleAccount
186190
handler.syncAccountPlanOnReset = handler.syncSingleAccountPlanOnReset
191+
handler.resetRadarHookRunner = handler.runResetRadarSignalHook
187192
if db != nil {
188193
if err := db.MarkInterruptedImageJobs(context.Background()); err != nil {
189194
log.Printf("标记中断生图任务失败: %v", err)
@@ -264,6 +269,7 @@ func (h *Handler) RegisterRoutes(r *gin.Engine) {
264269
api.GET("/ops/errors", h.GetOpsErrorLogs)
265270
api.GET("/ops/errors/export", h.ExportOpsErrorLogs)
266271
api.GET("/ops/errors/summary", h.GetOpsErrorSummary)
272+
api.GET("/reset-radar", h.GetResetRadar)
267273
api.GET("/settings", h.GetSettings)
268274
api.PUT("/settings", h.UpdateSettings)
269275
api.POST("/settings/background-upload", h.UploadBackgroundAsset)

0 commit comments

Comments
 (0)