feat(reports): align first response distribution range
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user