pull/2206/head
Ayrat Badykov 6 years ago
parent ac56c61784
commit 78a5010662
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 12
      apps/explorer/lib/explorer/chain/address_transaction_csv_exporter.ex

@ -1,7 +1,11 @@
defmodule Explorer.Chain.AddressTransactionCsvExporter do
alias Explorer.Chain
@moduledoc """
Exports transactions to a csv file.
"""
alias Explorer.{Chain, PagingOptions}
alias Explorer.Chain.{Address, Transaction}
alias Explorer.PagingOptions
alias NimbleCSV.RFC4180
@necessity_by_association [
necessity_by_association: %{
@ -20,6 +24,7 @@ defmodule Explorer.Chain.AddressTransactionCsvExporter do
@paging_options %PagingOptions{page_size: @page_size + 1}
@spec export(Address.t()) :: String.t()
def export(address) do
address
|> fetch_all_transactions(@paging_options)
@ -47,8 +52,9 @@ defmodule Explorer.Chain.AddressTransactionCsvExporter do
defp dump_data_to_csv(transactions) do
{:ok, path} = Briefly.create()
_ =
transactions
|> NimbleCSV.RFC4180.dump_to_stream()
|> RFC4180.dump_to_stream()
|> Stream.into(File.stream!(path))
|> Enum.to_list()

Loading…
Cancel
Save