Skip to content

Commit

Permalink
update all takings with canceled events
Browse files Browse the repository at this point in the history
  • Loading branch information
deinelieblings committed Sep 21, 2023
1 parent c0c3471 commit 5572d03
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions dao/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func UpdateDatabase() {
UpdateDepositUnitCurrency(ctx)
InsertUpdate(ctx, "deposit_unit_currency")
}
if !CheckUpdated(ctx, "taking_no_income_event_canceled") {
UpdateEventCanceledNoIncome(ctx)
InsertUpdate(ctx, "taking_no_income_event_canceled")
}
}

func UpdateCrewMaibox(ctx context.Context) {
Expand Down Expand Up @@ -139,3 +143,18 @@ func UpdateDepositUnitCurrency(ctx context.Context) {
return
}
}

func UpdateEventCanceledNoIncome(ctx context.Context) {
filterEvent := bson.D{{Key: "event_state.state", Value: "canceled"}}
eventResult := []models.Event{}
if err := EventCollection.Find(ctx, filterEvent, &eventResult); err != nil {
return
}
for _, value := range eventResult {
updateTaking := bson.D{{Key: "state.no_income", Value: true}}
filterTaking := bson.D{{Key: "_id", Value: value.TakingID}}
if err := TakingCollection.UpdateOne(ctx, filterTaking, vmdb.UpdateSet(updateTaking), nil); err != nil {
return
}
}
}

0 comments on commit 5572d03

Please sign in to comment.