From 337c80f2bf26b1cc925e95a0024a0696ea5201ed Mon Sep 17 00:00:00 2001 From: Conor Macpherson Date: Fri, 6 Jan 2023 11:08:51 -0500 Subject: [PATCH] Create true up review earlier, move completed check to be earlier. --- api4/license.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/api4/license.go b/api4/license.go index 880447ed58..69537ba9e5 100644 --- a/api4/license.go +++ b/api4/license.go @@ -318,6 +318,18 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) { return } + status, appErr := c.App.GetOrCreateTrueUpReviewStatus() + if appErr != nil { + c.Err = appErr + return + } + + // If a true up review has already been submitted for the current due date, complete the request + // with no errors. + if status.Completed { + ReturnStatusOK(w) + } + profileMap, err := c.App.GetTrueUpProfile() if err != nil { c.Err = model.NewAppError("requestTrueUpReview", "api.license.true_up_review.get_status_error", nil, "", http.StatusInternalServerError) @@ -330,16 +342,10 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) { return } - status, appErr := c.App.GetOrCreateTrueUpReviewStatus() - if err != nil { - c.Err = appErr - return - } - // Do not send true-up review data if the user has already requested one for the quarter. // And only send a true-up review via as a one-time telemetry request if telemetry is disabled. telemetryEnabled := c.App.Config().LogSettings.EnableDiagnostics - if !status.Completed && telemetryEnabled != nil && !*telemetryEnabled { + if telemetryEnabled != nil && !*telemetryEnabled { // Send telemetry data c.App.Srv().GetTelemetryService().SendTelemetry(model.TrueUpReviewTelemetryName, profileMap)