feat(reports): align first response distribution range

This commit is contained in:
2026-06-07 01:49:30 +08:00
parent 2453a84098
commit dd23de4e53
5 changed files with 66 additions and 6 deletions
+20 -1
View File
@@ -566,7 +566,7 @@ func (h *AnalyticsHandler) FirstResponseTimeDistribution(c *gin.Context) {
if !ok {
return
}
since, until, ok := parseDateRange(c)
since, until, ok := parseOptionalReportDateRange(c)
if !ok {
return
}
@@ -581,6 +581,25 @@ func (h *AnalyticsHandler) FirstResponseTimeDistribution(c *gin.Context) {
c.JSON(http.StatusOK, result)
}
func parseOptionalReportDateRange(c *gin.Context) (since, until time.Time, ok bool) {
sinceRaw := c.Query("since")
untilRaw := c.Query("until")
if sinceRaw == "" || untilRaw == "" {
return time.Time{}, time.Time{}, true
}
since, err := parseChatwootReportTime(sinceRaw)
if err != nil {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid since date format")
return time.Time{}, time.Time{}, false
}
until, err = parseChatwootReportTime(untilRaw)
if err != nil {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid until date format")
return time.Time{}, time.Time{}, false
}
return since, until, true
}
// OutgoingMessagesCount returns outgoing message count metrics.
// GET /api/v1/accounts/:account_id/reports/outgoing_messages_count
// Reference: Chatwoot reports#outgoing_messages_count