@@ -25,7 +25,7 @@ import (
2525type TimeRangeRequest struct {
2626 From * time.Time `json:"from" schema:"from"`
2727 To * time.Time `json:"to" schema:"to"`
28- TimeWindow * TimeWindows `json:"timeWindow" schema:"timeWindow" validate:"omitempty,oneof=today yesterday week month quarter lastWeek lastMonth lastQuarter last7Days last30Days last90Days"`
28+ TimeWindow * TimeWindows `json:"timeWindow" schema:"timeWindow" validate:"omitempty,oneof=today yesterday week month quarter lastWeek lastMonth lastQuarter last24Hours last7Days last30Days last90Days"`
2929}
3030
3131func NewTimeRangeRequest (from * time.Time , to * time.Time ) * TimeRangeRequest {
@@ -59,6 +59,7 @@ const (
5959 LastMonth TimeWindows = "lastMonth"
6060 Year TimeWindows = "year"
6161 LastQuarter TimeWindows = "lastQuarter"
62+ Last24Hours TimeWindows = "last24Hours"
6263 Last7Days TimeWindows = "last7Days"
6364 Last30Days TimeWindows = "last30Days"
6465 Last90Days TimeWindows = "last90Days"
@@ -143,6 +144,9 @@ func (timeRange *TimeRangeRequest) ParseAndValidateTimeRange() (*TimeRangeReques
143144 case Year :
144145 start := time .Date (now .Year (), 1 , 1 , 0 , 0 , 0 , 0 , now .Location ())
145146 return NewTimeRangeRequest (& start , & now ), nil
147+ case Last24Hours :
148+ start := now .Add (- 24 * time .Hour )
149+ return NewTimeRangeRequest (& start , & now ), nil
146150 case Last7Days :
147151 start := now .AddDate (0 , 0 , - 7 )
148152 return NewTimeRangeRequest (& start , & now ), nil
0 commit comments