Skip to content

Commit

Permalink
Fix: one ticket to all updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Sep 28, 2023
1 parent 7662312 commit fb887c0
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions internal/parsers/operations/ticket_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ func (p *TicketUpdateParser) Parse(data *noderpc.OperationResult, operation *ope
}

func (p *TicketUpdateParser) toModel(data noderpc.TicketUpdate, operation *operation.Operation, store parsers.Store) []*ticket.TicketUpdate {
tckt := ticket.Ticket{
ContentType: data.TicketToken.ContentType,
Content: data.TicketToken.Content,
Ticketer: account.Account{
Address: data.TicketToken.Ticketer,
Type: types.NewAccountType(data.TicketToken.Ticketer),
Level: operation.Level,
LastAction: operation.Timestamp,
TicketUpdatesCount: 1,
},
UpdatesCount: 1,
Level: operation.Level,
}
store.AddTickets(&tckt)

updates := make([]*ticket.TicketUpdate, 0)
for i := range data.Updates {
tckt := ticket.Ticket{
ContentType: data.TicketToken.ContentType,
Content: data.TicketToken.Content,
Ticketer: account.Account{
Address: data.TicketToken.Ticketer,
Type: types.NewAccountType(data.TicketToken.Ticketer),
Level: operation.Level,
LastAction: operation.Timestamp,
TicketUpdatesCount: 1,
},
UpdatesCount: 1,
Level: operation.Level,
}
update := ticket.TicketUpdate{
Level: operation.Level,
Timestamp: operation.Timestamp,
Expand All @@ -60,7 +62,6 @@ func (p *TicketUpdateParser) toModel(data noderpc.TicketUpdate, operation *opera
Amount: decimal.RequireFromString(data.Updates[i].Amount),
}
updates = append(updates, &update)
store.AddTickets(&tckt)
store.AddAccounts(&update.Account, &tckt.Ticketer)
store.AddTicketBalances(&ticket.Balance{
Account: update.Account,
Expand Down

0 comments on commit fb887c0

Please sign in to comment.