Skip to content

Commit

Permalink
do not call api if list empty
Browse files Browse the repository at this point in the history
  • Loading branch information
acoshift committed Dec 25, 2023
1 parent dc570e9 commit aaf9fb0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ func (w *Worker) syncProjectUsageDate(ctx context.Context, p *api.CollectorProje
Value: value,
})

if len(req.Resources) == 0 {
return
}

_, err = w.Client.Collector().SetProjectUsage(ctx, &req)
if err != nil {
slog.Error("collector: set project usage error", "error", err)
Expand Down Expand Up @@ -290,6 +294,10 @@ func (w *Worker) syncDeploymentUsage(ctx context.Context) {
})
}

if len(req.List) == 0 {
return nil
}

_, err = w.Client.Collector().SetDeploymentUsage(ctx, &req)
if err != nil {
slog.Error("collector: sync deployment error", "name", name, "error", err)
Expand Down Expand Up @@ -337,6 +345,10 @@ func (w *Worker) syncDeploymentUsage(ctx context.Context) {
})
}

if len(req.List) == 0 {
return nil
}

_, err = w.Client.Collector().SetDiskUsage(ctx, &req)
if err != nil {
slog.Error("collector: sync disk error", "name", name, "error", err)
Expand Down

0 comments on commit aaf9fb0

Please sign in to comment.