From 44d1655a6fe0fbed9a251019beb01026738e2acf Mon Sep 17 00:00:00 2001 From: Mauricio Araujo Date: Mon, 20 May 2024 13:08:49 -0400 Subject: [PATCH] Clean up nested condition --- internal/billing/usage.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/billing/usage.go b/internal/billing/usage.go index 5cfdc03214..e59e327e7f 100644 --- a/internal/billing/usage.go +++ b/internal/billing/usage.go @@ -380,13 +380,14 @@ func (m LagoClient) IngestEvents(ctx context.Context, subscriptionID string, eve batch := events[i:end] var batchInput []lago.EventInput for i := range batch { + projectID, err := strconv.ParseUint(batch[i].CustomerID, 10, 64) + if err != nil { + return telemetry.Error(ctx, span, err, "failed to parse project id") + } + if enableSandbox { // For Porter Cloud, we can't infer the project ID from the request, so we - // instead extract it from the billing events - projectID, err := strconv.ParseUint(batch[i].CustomerID, 10, 64) - if err != nil { - return telemetry.Error(ctx, span, err, "failed to parse project id") - } + // instead use the one in the billing event subscriptionID = m.generateLagoID(SubscriptionIDPrefix, uint(projectID), enableSandbox) }