Skip to content

Commit

Permalink
Try with a map to clean up the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Bellamy committed Jun 7, 2021
1 parent 9947940 commit ee37850
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions services/horizon/internal/db2/history/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,18 +826,17 @@ func (q *Q) CloneIngestionQ() IngestionQ {
// DeleteRangeAll deletes a range of rows from all history tables between
// `start` and `end` (exclusive).
func (q *Q) DeleteRangeAll(ctx context.Context, start, end int64) error {
for _, pair := range [][2]string{
{"history_effects", "history_operation_id"},
{"history_operation_claimable_balances", "history_operation_id"},
{"history_operation_participants", "history_operation_id"},
{"history_operations", "id"},
{"history_transaction_claimable_balances", "history_transaction_id"},
{"history_transaction_participants", "history_transaction_id"},
{"history_transactions", "id"},
{"history_ledgers", "id"},
{"history_trades", "history_operation_id"},
for table, column := range map[string]string{
"history_effects": "history_operation_id",
"history_ledgers": "id",
"history_operation_claimable_balances": "history_operation_id",
"history_operation_participants": "history_operation_id",
"history_operations": "id",
"history_trades": "history_operation_id",
"history_transaction_claimable_balances": "history_transaction_id",
"history_transaction_participants": "history_transaction_id",
"history_transactions": "id",
} {
table, column := pair[0], pair[1]
err := q.DeleteRange(ctx, start, end, table, column)
if err != nil {
return errors.Wrapf(err, "Error clearing %s", table)
Expand Down

0 comments on commit ee37850

Please sign in to comment.