View Source Plausible.Exports (Plausible v0.0.1)

Contains functions to export data for events and sessions as Zip archives.

Summary

Functions

Link to this function

export_browsers_q(site_id)

View Source
@spec export_browsers_q(pos_integer()) :: Ecto.Query.t()
Link to this function

export_devices_q(site_id)

View Source
@spec export_devices_q(pos_integer()) :: Ecto.Query.t()
Link to this function

export_entry_pages_q(site_id)

View Source
@spec export_entry_pages_q(pos_integer()) :: Ecto.Query.t()
Link to this function

export_exit_pages_q(site_id)

View Source
@spec export_exit_pages_q(pos_integer()) :: Ecto.Query.t()
Link to this function

export_locations_q(site_id)

View Source
@spec export_locations_q(pos_integer()) :: Ecto.Query.t()
Link to this function

export_operating_systems_q(site_id)

View Source
@spec export_operating_systems_q(pos_integer()) :: Ecto.Query.t()
@spec export_pages_q(pos_integer()) :: Ecto.Query.t()
Link to this function

export_queries(site_id, opts \\ [])

View Source
@spec export_queries(pos_integer(), extname: String.t(), date_range: Date.Range.t()) ::
  %{
    required(String.t()) => Ecto.Query.t()
  }

Builds Ecto queries to export data from events_v2 and sessions_v2 tables into the format of imported_* tables for a website.

Link to this function

export_sources_q(site_id)

View Source
@spec export_sources_q(pos_integer()) :: Ecto.Query.t()
Link to this function

export_visitors_q(site_id)

View Source
@spec export_visitors_q(pos_integer()) :: Ecto.Query.t()
Link to this function

stream_archive(conn, named_queries, opts \\ [])

View Source
@spec stream_archive(DBConnection.t(), %{required(String.t()) => Ecto.Query.t()}, [
  Ch.query_option()
]) ::
  Enumerable.t()

Creates a streamable Zip archive from the provided (named) Ecto queries.

Example usage:

{:ok, pool} = Ch.start_link(pool_size: 1)

DBConnection.run(pool, fn conn ->
  conn
  |> stream_archive(export_queries(_site_id = 1), format: "CSVWithNames")
  |> Stream.into(File.stream!("export.zip"))
  |> Stream.run()
end)