feat(reports): align v2 timeseries timezones
This commit is contained in:
@@ -49,7 +49,11 @@ func (h *AnalyticsHandler) Index(c *gin.Context) {
|
||||
id = uint(parsed)
|
||||
}
|
||||
businessHours := c.Query("business_hours") == "true" || c.Query("business_hours") == "1"
|
||||
result, err := h.svc.GetTimeseries(c.Request.Context(), accountID, metric, since, until, c.DefaultQuery("type", "account"), id, c.Query("group_by"), businessHours)
|
||||
timezoneOffset, ok := parseReportTimezoneOffset(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
result, err := h.svc.GetTimeseries(c.Request.Context(), accountID, metric, since, until, c.DefaultQuery("type", "account"), id, c.Query("group_by"), timezoneOffset, businessHours)
|
||||
if err != nil {
|
||||
applogger.L().Errorf("Timeseries report: %v", err)
|
||||
response.AbortWithStatusError(c, http.StatusInternalServerError, response.ErrInternal, "failed to generate report")
|
||||
@@ -105,15 +109,22 @@ func parseReportBusinessHours(c *gin.Context) bool {
|
||||
return c.Query("business_hours") == "true" || c.Query("business_hours") == "1"
|
||||
}
|
||||
|
||||
func parseConversationTrafficRange(c *gin.Context) (time.Time, time.Time, float64, bool) {
|
||||
timezoneOffset := 0.0
|
||||
func parseReportTimezoneOffset(c *gin.Context) (float64, bool) {
|
||||
if raw := c.Query("timezone_offset"); raw != "" {
|
||||
parsed, err := strconv.ParseFloat(raw, 64)
|
||||
if err != nil {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid timezone_offset")
|
||||
return time.Time{}, time.Time{}, 0, false
|
||||
return 0, false
|
||||
}
|
||||
timezoneOffset = parsed
|
||||
return parsed, true
|
||||
}
|
||||
return 0, true
|
||||
}
|
||||
|
||||
func parseConversationTrafficRange(c *gin.Context) (time.Time, time.Time, float64, bool) {
|
||||
timezoneOffset, ok := parseReportTimezoneOffset(c)
|
||||
if !ok {
|
||||
return time.Time{}, time.Time{}, 0, false
|
||||
}
|
||||
|
||||
if c.Query("since") != "" || c.Query("until") != "" {
|
||||
|
||||
Reference in New Issue
Block a user