Fix user metric update batch ordering

This commit is contained in:
zhx 2026-05-26 15:35:16 +08:00
parent d67220aa5e
commit d7f507916f

View File

@ -191,6 +191,20 @@ func (r *MySQLRepository) ApplyContributionBatch(ctx context.Context, tx *sql.Tx
}
}
for _, c := range negative {
if err := r.ApplyDailyContribution(ctx, tx, c, storageTimezone); err != nil {
return err
}
for _, statTimezone := range statTimezones {
if err := r.ApplyPeriodContribution(ctx, tx, c, statTimezone); err != nil {
return err
}
if err := r.ApplyGamePeriodContribution(ctx, tx, c, statTimezone); err != nil {
return err
}
}
}
for key, totals := range dailyAmounts {
if totals.empty() {
continue
@ -230,19 +244,6 @@ func (r *MySQLRepository) ApplyContributionBatch(ctx context.Context, tx *sql.Tx
return err
}
}
for _, c := range negative {
if err := r.ApplyDailyContribution(ctx, tx, c, storageTimezone); err != nil {
return err
}
for _, statTimezone := range statTimezones {
if err := r.ApplyPeriodContribution(ctx, tx, c, statTimezone); err != nil {
return err
}
if err := r.ApplyGamePeriodContribution(ctx, tx, c, statTimezone); err != nil {
return err
}
}
}
return nil
}