Skip to content

Commit

Permalink
add support of [[.NOW]] template expansion for mongo provider
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Sep 10, 2024
1 parent 48b2abc commit 35b3a2f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/status/external/mongo_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ type DayTemplate struct {
YYYYMMDD5 string // -5 days
YYYYMMDD6 string // -6 days
YYYYMMDD7 string // -7 days
NOW string // now time, with seconds precision
}

// NewDayTemplate makes day parser for given date
Expand All @@ -247,6 +248,8 @@ func NewDayTemplate(ts time.Time) *DayTemplate {
YYYYMMDD5: fmt.Sprintf(`{"$date":"%04d-%02d-%02dT%02d:%02d:%02dZ"}`,
lts.AddDate(0, 0, -5).Year(), lts.AddDate(0, 0, -5).Month(), lts.AddDate(0, 0, -5).Day(),
lts.AddDate(0, 0, -5).Hour(), lts.AddDate(0, 0, -5).Minute(), lts.AddDate(0, 0, -5).Second()),
NOW: fmt.Sprintf(`{"$date":"%04d-%02d-%02dT%02d:%02d:%02dZ"}`,
lts.Year(), lts.Month(), lts.Day(), lts.Hour(), lts.Minute(), lts.Second()),
}

return d
Expand Down

0 comments on commit 35b3a2f

Please sign in to comment.