add additional fields to csv file

pull/2206/head
Ayrat Badykov 6 years ago
parent 78a5010662
commit 4ea5e97306
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 8
      apps/explorer/lib/explorer/chain/address_transaction_csv_exporter.ex
  2. 32
      apps/explorer/test/explorer/chain/address_transaction_csv_exporter_test.exs

@ -71,7 +71,9 @@ defmodule Explorer.Chain.AddressTransactionCsvExporter do
"ToAddress",
"ContractAddress",
"Type",
"Value"
"Value",
"Status",
"ErrCode"
]
transaction_lists =
@ -85,7 +87,9 @@ defmodule Explorer.Chain.AddressTransactionCsvExporter do
to_string(transaction.to_address),
to_string(transaction.created_contract_address),
type(transaction, address),
1
1,
transaction.status,
transaction.error
]
end)

@ -18,7 +18,18 @@ defmodule Explorer.Chain.AddressTransactionCsvExporterTest do
|> AddressTransactionCsvExporter.export()
|> File.stream!()
|> NimbleCSV.RFC4180.parse_stream()
|> Stream.map(fn [hash, block_number, timestamp, from_address, to_address, created_address, type, value] ->
|> Stream.map(fn [
hash,
block_number,
timestamp,
from_address,
to_address,
created_address,
type,
value,
status,
error
] ->
%{
hash: hash,
block_number: block_number,
@ -27,7 +38,9 @@ defmodule Explorer.Chain.AddressTransactionCsvExporterTest do
to_address: to_address,
created_address: created_address,
type: type,
value: value
value: value,
status: status,
error: error
}
end)
|> Enum.to_list()
@ -38,6 +51,9 @@ defmodule Explorer.Chain.AddressTransactionCsvExporterTest do
assert result.to_address == to_string(transaction.to_address)
assert result.hash == to_string(transaction.hash)
assert result.type == "OUT"
assert result.value == "1"
assert result.status == to_string(transaction.status)
assert result.error == to_string(transaction.error)
end
test "fetches all transactions" do
@ -56,18 +72,6 @@ defmodule Explorer.Chain.AddressTransactionCsvExporterTest do
|> AddressTransactionCsvExporter.export()
|> File.stream!()
|> NimbleCSV.RFC4180.parse_stream()
|> Stream.map(fn [hash, block_number, timestamp, from_address, to_address, created_address, type, value] ->
%{
hash: hash,
block_number: block_number,
timestamp: timestamp,
from_address: from_address,
to_address: to_address,
created_address: created_address,
type: type,
value: value
}
end)
|> Enum.to_list()
assert Enum.count(result) == 200

Loading…
Cancel
Save