class IssuesAndConcernsReportsController < ApplicationController
  def show
    respond_to do |format|
      format.xlsx { send_issues_and_concerns_report_xls }
    end
  end

  private

  def videos
    policy_scope(Video)
  end

  def video
    authorize videos.find(params[:video_id])
  end

  def issues_and_concerns_report
    authorize ExcelReports::IssuesAndConcernsReports::IssuesAndConcernsReport.new(video)
  end

  def send_issues_and_concerns_report_xls
    send_data(
      issues_and_concerns_report.to_xls,
      {
        filename: issues_and_concerns_report.filename,
        type: Mime[:xlsx]
      }
    )
  end
end
