From d5261744dbbc8bfd771ff43cc55445a7601f823c Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Wed, 28 Apr 2021 18:12:32 +0300 Subject: [PATCH] Add order by token.type (cherry picked from commit a01f4ab2c5b44e58c8d6c345d4db58bd07aab964) --- apps/explorer/lib/explorer/chain/import/runner/blocks.ex | 2 ++ apps/explorer/lib/explorer/chain/import/runner/tokens.ex | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex index b8d67208ce..7eefc7353b 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex @@ -344,6 +344,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do select: map(tb, [:address_hash, :token_contract_address_hash, :block_number]), # Enforce TokenBalance ShareLocks order (see docs: sharelocks.md) order_by: [ + tb.token_type, tb.token_contract_address_hash, tb.address_hash, tb.block_number @@ -381,6 +382,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do select: map(ctb, [:address_hash, :token_contract_address_hash]), # Enforce CurrentTokenBalance ShareLocks order (see docs: sharelocks.md) order_by: [ + ctb.token_type, ctb.token_contract_address_hash, ctb.address_hash ], diff --git a/apps/explorer/lib/explorer/chain/import/runner/tokens.ex b/apps/explorer/lib/explorer/chain/import/runner/tokens.ex index d6a254911c..b1fff314f4 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/tokens.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/tokens.ex @@ -27,7 +27,10 @@ defmodule Explorer.Chain.Import.Runner.Tokens do token in Token, where: token.contract_address_hash in ^contract_address_hashes, # Enforce Token ShareLocks order (see docs: sharelocks.md) - order_by: token.contract_address_hash, + order_by: [ + token.type, + token.contract_address_hash + ], lock: "FOR UPDATE" )