@@ -41,7 +41,7 @@ defmodule Mobilizon.Service.Export.Participants.CSV do
|
||||
|> Repo.stream()
|
||||
|> Stream.map(&to_list/1)
|
||||
|> NimbleCSV.RFC4180.dump_to_iodata()
|
||||
|> (fn stream -> Stream.concat([Enum.join(columns(), ","), "\n"], stream) end).()
|
||||
|> add_header_column()
|
||||
|> Stream.each(fn line -> IO.write(file, line) end)
|
||||
|> Stream.run()
|
||||
|
||||
@@ -63,6 +63,10 @@ defmodule Mobilizon.Service.Export.Participants.CSV do
|
||||
end
|
||||
end
|
||||
|
||||
defp add_header_column(stream) do
|
||||
Stream.concat([Enum.join(columns(), ","), "\n"], stream)
|
||||
end
|
||||
|
||||
@spec save_csv_upload(String.t(), String.t(), Event.t()) ::
|
||||
{:ok, Export.t()} | {:error, atom() | Ecto.Changeset.t()}
|
||||
defp save_csv_upload(full_path, filename, %Event{id: event_id, title: title}) do
|
||||
|
||||
@@ -39,7 +39,7 @@ defmodule Mobilizon.Service.Export.Participants.ODS do
|
||||
|> Events.participant_for_event_export_query(Keyword.get(options, :roles, []))
|
||||
|> Repo.all()
|
||||
|> Enum.map(&to_list/1)
|
||||
|> (fn data -> Enum.concat([columns()], data) end).()
|
||||
|> add_header_columns()
|
||||
|> generate_ods()
|
||||
|
||||
File.write!(full_path, content)
|
||||
@@ -62,6 +62,10 @@ defmodule Mobilizon.Service.Export.Participants.ODS do
|
||||
end
|
||||
end
|
||||
|
||||
defp add_header_columns(data) do
|
||||
Enum.concat([columns()], data)
|
||||
end
|
||||
|
||||
defp generate_ods(data) do
|
||||
data
|
||||
|> Jason.encode!()
|
||||
|
||||
Reference in New Issue
Block a user