From edfd8b5f5474d2c76a018f7f7e19e1c7a5916539 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Wed, 21 Feb 2024 16:16:07 +0000 Subject: [PATCH] feat(billing): Support -/+ infinity This updates the billing repository to use timestmap.Timestamp when constructing the queries to retrieve monthly active users. This allows for specifying NegativeInfinity to easily retrieve all monthly active user counts. --- internal/billing/repository.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/billing/repository.go b/internal/billing/repository.go index 0c9a9a6597..80385dc556 100644 --- a/internal/billing/repository.go +++ b/internal/billing/repository.go @@ -9,6 +9,7 @@ import ( "time" "github.com/hashicorp/boundary/internal/db" + "github.com/hashicorp/boundary/internal/db/timestamp" "github.com/hashicorp/boundary/internal/errors" ) @@ -65,7 +66,7 @@ func (r *Repository) MonthlyActiveUsers(ctx context.Context, opt ...Option) ([]A } query = activeUsersWithStartTimeQuery args = append(args, - sql.Named("start_time", opts.withStartTime)) + sql.Named("start_time", timestamp.New(*opts.withStartTime))) } if opts.withEndTime != nil { if *opts.withEndTime != time.Date(opts.withEndTime.Year(), opts.withEndTime.Month(), 1, 0, 0, 0, 0, time.UTC) { @@ -73,7 +74,7 @@ func (r *Repository) MonthlyActiveUsers(ctx context.Context, opt ...Option) ([]A } query = activeUsersWithStartTimeAndEndTimeQuery args = append(args, - sql.Named("end_time", opts.withEndTime)) + sql.Named("end_time", timestamp.New(*opts.withEndTime))) } var activeUsers []ActiveUsers