Skip to Content Skip to Search
Methods
C

Instance Public methods

create()

# File engines/admin/app/controllers/admin/members/exports_controller.rb, line 12
def create
  searcher = Action::MemberSearcher.new(@site, params.permit!)

  if searcher.results.count > 999 || params[:export_format] == "analytics_summary"
    ExportMembersJob.perform_later(
      recipient_id: current_member.id,
      site_id: @site.id,
      params: params.permit!.to_h
    )

    flash[:success] = "Your export is processing, we will email you the CSV file as soon as it's ready."

    redirect_to site_members_path(@site)
  else
    exporter = MembersExporter.new(
      site: @site,
      searcher:,
      plan_id: params[:plan_id],
      export_format: params[:export_format]
    )

    exporter.generate

    send_file exporter.file_path,
      type: "text/csv;charset=iso-8859-1;header=present",
      disposition: "attachment",
      filename: exporter.file_name
  end
end