diff --git a/app/multitenant/aws_collector.go b/app/multitenant/aws_collector.go index 29a8bebd6..3a4a66144 100644 --- a/app/multitenant/aws_collector.go +++ b/app/multitenant/aws_collector.go @@ -274,11 +274,9 @@ func (c *awsCollector) reportKeysInRange(ctx context.Context, userid string, row return result, nil } -// getReportKeys returns the S3 for reports in the reporting window ending at timestamp. -func (c *awsCollector) getReportKeys(ctx context.Context, timestamp time.Time) ([]string, error) { +// getReportKeys returns the S3 for reports in the interval [start, end]. +func (c *awsCollector) getReportKeys(ctx context.Context, start, end time.Time) ([]string, error) { var ( - end = timestamp - start = end.Add(-c.cfg.Window) rowStart = start.UnixNano() / time.Hour.Nanoseconds() rowEnd = end.UnixNano() / time.Hour.Nanoseconds() ) @@ -351,7 +349,9 @@ func (c *awsCollector) getReports(ctx context.Context, reportKeys []string) ([]r func (c *awsCollector) Report(ctx context.Context, timestamp time.Time) (report.Report, error) { span, ctx := opentracing.StartSpanFromContext(ctx, "awsCollector.Report") defer span.Finish() - reportKeys, err := c.getReportKeys(ctx, timestamp) + end := timestamp + start := end.Add(-c.cfg.Window) + reportKeys, err := c.getReportKeys(ctx, start, end) if err != nil { return report.MakeReport(), err } @@ -366,7 +366,8 @@ func (c *awsCollector) Report(ctx context.Context, timestamp time.Time) (report. } func (c *awsCollector) HasReports(ctx context.Context, timestamp time.Time) (bool, error) { - reportKeys, err := c.getReportKeys(ctx, timestamp) + start := timestamp.Add(-c.cfg.Window) + reportKeys, err := c.getReportKeys(ctx, start, timestamp) return len(reportKeys) > 0, err }