fix(ticket): guard stale responses and stale hours

This commit is contained in:
mlogclub
2026-05-02 20:20:30 +08:00
parent 8a8b92a307
commit 8102f89308
5 changed files with 61 additions and 21 deletions
@@ -2,12 +2,10 @@ package dashboard
import (
"strings"
"time"
"cs-agent/internal/builders"
"cs-agent/internal/pkg/constants"
"cs-agent/internal/pkg/dto/request"
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
@@ -46,9 +44,7 @@ func (c *TicketController) AnyList() *web.JsonResult {
cnd.Eq("current_assignee_id", 0)
}
if staleHours, _ := params.GetInt(c.Ctx, "staleHours"); staleHours > 0 {
cnd.
NotEq("status", enums.TicketStatusDone).
Where("updated_at < ?", time.Now().Add(-time.Duration(staleHours)*time.Hour))
services.TicketService.ApplyStaleFilter(cnd, staleHours)
}
aggregate, err := services.TicketService.FindPageAggregateByCnd(cnd, operator.UserID)
if err != nil {