feat(reports): align conversation agent metrics

This commit is contained in:
2026-06-07 01:15:25 +08:00
parent 18f6403128
commit 108aae44b2
6 changed files with 171 additions and 17 deletions
+8 -2
View File
@@ -416,11 +416,17 @@ func (h *AnalyticsHandler) Conversations(c *gin.Context) {
reportType := c.Query("type")
if reportType == "" {
// Reference: Chatwoot returns head :unprocessable_entity if type is blank
response.AbortWithStatusError(c, http.StatusUnprocessableEntity, response.ErrBadRequest, "type parameter is required")
c.Status(http.StatusUnprocessableEntity)
return
}
page := 1
if rawPage := c.Query("page"); rawPage != "" {
if parsed, err := strconv.Atoi(rawPage); err == nil && parsed > 0 {
page = parsed
}
}
result, err := h.svc.GetConversationsByType(c.Request.Context(), accountID, reportType, time.Time{}, time.Time{})
result, err := h.svc.GetConversationsByType(c.Request.Context(), accountID, reportType, page)
if err != nil {
applogger.L().Errorf("Conversations report: %v", err)
response.AbortWithStatusError(c, http.StatusInternalServerError, response.ErrInternal, "failed to generate conversations report")