Skip to content

Commit

Permalink
ResourceUtilizationRangeForTeam should always return one row
Browse files Browse the repository at this point in the history
  • Loading branch information
thokra-nav committed Apr 16, 2024
1 parent 42d5cb9 commit c675b2f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/database/resource_utilization.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package database

import (
"context"
"errors"

"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
"github.com/nais/api/internal/database/gensql"
"github.com/nais/api/internal/slug"
Expand Down Expand Up @@ -75,7 +77,12 @@ func (d *database) ResourceUtilizationRangeForApp(ctx context.Context, environme
}

func (d *database) ResourceUtilizationRangeForTeam(ctx context.Context, teamSlug slug.Slug) (*gensql.ResourceUtilizationRangeForTeamRow, error) {
return d.querier.ResourceUtilizationRangeForTeam(ctx, teamSlug)
row, err := d.querier.ResourceUtilizationRangeForTeam(ctx, teamSlug)
if errors.Is(err, pgx.ErrNoRows) {
return &gensql.ResourceUtilizationRangeForTeamRow{}, nil
}

return row, err
}

func (d *database) SpecificResourceUtilizationForApp(ctx context.Context, environment string, teamSlug slug.Slug, app string, resourceType gensql.ResourceType, timestamp pgtype.Timestamptz) (*gensql.SpecificResourceUtilizationForAppRow, error) {
Expand Down

0 comments on commit c675b2f

Please sign in to comment.