Updated

app/controllers/admin / statistics_controller.rb

A
43 lines of codes
6 methods
5.2 complexity/method
1 churn
31.37 complexity
0 duplications
require 'csv' class Admin::StatisticsController < Admin::AdminController
  1. Admin::StatisticsController has no descriptive comment
after_action :set_content_disposition, if: :csv_request?, except: [:index] def index respond_to do |format| format.html end end def moderation @rows = Statistics.moderation(by: period, parliament: parliament) respond_to do |format| format.csv end end private def parliament if params.key?(:parliament) Parliament.find(params[:parliament]) end end def period params[:period] end def csv_filename if params.key?(:parliament) "#{action_name}-#{parliament.period}-by-#{period}.csv" else "#{action_name}-by-#{period}.csv" end end def set_content_disposition response.headers['Content-Disposition'] = "attachment; filename=#{csv_filename}" end end