Remove order from SkippedReceipts and add appropriate indexes

pull/3/head
Doc Ritezel 7 years ago
parent d15d695dff
commit 8063839747
  1. 1
      lib/explorer/skipped_receipts.ex
  2. 3
      priv/repo/migrations/20180212214442_create_transaction_receipts.exs
  3. 9
      priv/repo/migrations/20180212222309_create_logs.exs
  4. 6
      test/explorer/skipped_transactions_test.exs

@ -13,7 +13,6 @@ defmodule Explorer.SkippedReceipts do
left_join: receipt in assoc(transaction, :receipt),
select: fragment("hash"),
where: is_nil(receipt.id),
order_by: [desc: fragment("lower(hash)")],
limit: ^count
Repo.all(transactions)
end

@ -12,6 +12,7 @@ defmodule Explorer.Repo.Migrations.CreateTransactionReceipts do
end
create index(:transaction_receipts, :index)
create unique_index(:transaction_receipts, [:transaction_id, :index])
create index(:transaction_receipts, :status)
create unique_index(:transaction_receipts, :transaction_id)
end
end

@ -11,7 +11,16 @@ defmodule Explorer.Repo.Migrations.CreateLogs do
add :first_topic, :string, null: true
add :second_topic, :string, null: true
add :third_topic, :string, null: true
add :fourth_topic, :string, null: true
timestamps null: false
end
create index(:logs, :index)
create index(:logs, :first_topic)
create index(:logs, :second_topic)
create index(:logs, :third_topic)
create index(:logs, :fourth_topic)
create index(:logs, :address_id)
create unique_index(:logs, :transaction_receipt_id)
end
end

@ -44,12 +44,6 @@ defmodule Explorer.SkippedReceiptsTest do
assert SkippedReceipts.first(1) == ["0xBEE75"]
end
test "returns up to the requested number of skipped transaction hashes in insert order" do
insert(:transaction, %{hash: "0xBEE75"})
insert(:transaction, %{hash: "0xBE475"})
assert SkippedReceipts.first(1) == ["0xBEE75"]
end
test "returns all the skipped transaction hashes in random order" do
insert(:transaction, %{hash: "0xBEE75"})
insert(:transaction, %{hash: "0xBE475"})

Loading…
Cancel
Save