feat(reports): derive analytics aggregates
This commit is contained in:
@@ -187,6 +187,7 @@ func (h *AnalyticsHandler) ConversationTraffic(c *gin.Context) {
|
||||
|
||||
response.OK(c, result)
|
||||
}
|
||||
|
||||
// BotSummary returns bot-level summary metrics.
|
||||
// GET /api/v1/accounts/:account_id/reports/bot_summary
|
||||
// Reference: Chatwoot reports#bot_summary
|
||||
@@ -226,12 +227,7 @@ func (h *AnalyticsHandler) Conversations(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
since, until, ok := parseDateRange(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.svc.GetConversationsByType(c.Request.Context(), accountID, reportType, since, until)
|
||||
result, err := h.svc.GetConversationsByType(c.Request.Context(), accountID, reportType, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
applogger.L().Errorf("Conversations report: %v", err)
|
||||
response.AbortWithStatusError(c, http.StatusInternalServerError, response.ErrInternal, "failed to generate conversations report")
|
||||
@@ -341,8 +337,13 @@ func (h *AnalyticsHandler) OutgoingMessagesCount(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
groupBy := c.Query("group_by")
|
||||
if groupBy != "agent" && groupBy != "team" && groupBy != "inbox" && groupBy != "label" {
|
||||
response.AbortWithStatusError(c, http.StatusUnprocessableEntity, response.ErrBadRequest, "invalid group_by")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.svc.GetOutgoingMessagesCount(c.Request.Context(), accountID, since, until)
|
||||
result, err := h.svc.GetOutgoingMessagesCountGrouped(c.Request.Context(), accountID, since, until, groupBy)
|
||||
if err != nil {
|
||||
applogger.L().Errorf("Outgoing messages count report: %v", err)
|
||||
response.AbortWithStatusError(c, http.StatusInternalServerError, response.ErrInternal, "failed to generate outgoing messages count")
|
||||
|
||||
Reference in New Issue
Block a user