Skip to content

Commit 2d3a0e6

Browse files
committed
fix bug
1 parent a84dcc6 commit 2d3a0e6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cloudSync.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,18 @@ func ValidateExecutionUsage(ctx context.Context, orgId string) (*Org, error) {
913913
}
914914
}
915915

916+
// Fix Me: Add daily stats update script to append daily stats immdediately after day change and reset monthly stats on month change
917+
lastMonthlyReset := validationOrgStats.LastMonthlyResetMonth
918+
currentMonth := time.Now().UTC().Month()
919+
if int(lastMonthlyReset) != int(currentMonth) {
920+
validationOrgStats = handleDailyCacheUpdate(validationOrgStats)
921+
922+
err = SetOrgStatistics(ctx, *validationOrgStats, validationOrg.Id)
923+
if err != nil {
924+
log.Printf("[ERROR] Failed setting org statistics for monthly reset for %s (%s): %s ", validationOrg.Name, validationOrg.Id, err)
925+
}
926+
}
927+
916928
totalAppExecutions := validationOrgStats.MonthlyAppExecutions + validationOrgStats.MonthlyChildAppExecutions
917929
if validationOrg.Billing.InternalAppRunsHardLimit > 0 && totalAppExecutions > validationOrg.Billing.InternalAppRunsHardLimit {
918930
return validationOrg, errors.New(fmt.Sprintf("Org %s (%s) has exceeded app runs hard limit (%d/%d)", validationOrg.Name, validationOrg.Id, totalAppExecutions, validationOrg.Billing.InternalAppRunsHardLimit))

0 commit comments

Comments
 (0)