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. 18
      apps/explorer/lib/explorer/chain/address_transaction_csv_exporter.ex

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

Loading…
Cancel
Save