Skip to content

Commit

Permalink
fix incorrect error handling which affects teams with no data
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Mar 15, 2024
1 parent 9b9adb7 commit 471fdf5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 11 additions & 3 deletions internal/graph/resourceusage.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/resourceusage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (c *client) CurrentResourceUtilizationForTeam(ctx context.Context, team slu
}

if timeRange.To.Time.Before(time.Now().UTC().Add(-3 * time.Hour)) {
return nil, fmt.Errorf("no current data available for team %q", team)
return nil, nil
}

ts := pgtype.Timestamptz{}
Expand Down Expand Up @@ -207,6 +207,10 @@ func (c *client) ResourceUtilizationTrendForTeam(ctx context.Context, team slug.
return nil, err
}

if current == nil {
return nil, nil
}

ts := pgtype.Timestamptz{}
err = ts.Scan(current.Timestamp)
if err != nil {
Expand Down

0 comments on commit 471fdf5

Please sign in to comment.