Skip to content

Commit

Permalink
Fix events opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaptoss committed Sep 24, 2024
1 parent e959b35 commit ca53703
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/service/handlers/create_event_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,21 @@ func openEvents(r *http.Request, evType models.EventType) error {
return fmt.Errorf("select balances: %w", err)
}

balancesWithEvent := make(map[string]struct{})
existedEvents, err := EventsQ(r).FilterByType(evType.Name).Select()
if err != nil {
return fmt.Errorf("failed to select events with type %s: %w", evType.Name, err)
}

for _, existedEvent := range existedEvents {
balancesWithEvent[existedEvent.Nullifier] = struct{}{}
}

eventsToInsert := make([]data.Event, 0, len(balances))
for _, b := range balances {
if _, ok := balancesWithEvent[b.Nullifier]; ok {
continue
}
eventsToInsert = append(eventsToInsert, data.Event{
Nullifier: b.Nullifier,
Status: data.EventOpen,
Expand Down

0 comments on commit ca53703

Please sign in to comment.