app/controllers/admin_events_controller.rb
#Admin page view with all submitted events and admin statistics:
Admin page view with all submitted events and admin statistics.
Admin page view with all submitted events and admin statistics .
def index
    @application_process_options_handler = ApplicationProcessOptionsHandler.find(1)
    @events = Event.all
    @new_users = User.all.created_last_30_days
    @total_organizers = Event.all.total_organizers
    @countries = Event.all.pluck(:country).compact
    @countries_statistics = CountriesStatistics.new(@events).to_json
    @country_rank = CountriesStatistics.new(@events).country_rank
    @categorized_events = {
      "Unapproved events" => Event.unapproved.upcoming.order(:deadline),
      "Approved events" => Event.approved.upcoming.order(:deadline),
      "Past approved events"=> Event.approved.past.order(deadline: :desc).active,
      "Past unapproved events" => Event.unapproved.past.order(:deadline).active
    }
    @approved_events_deadline = {
      "Open deadline:" => Event.approved.upcoming.open.order(:deadline),
      "Closed deadline:" => Event.approved.upcoming.closed.order(:deadline)
    }
    respond_to do |format|
      format.html
      format.csv { send_data ReportExporter.events_report, filename: "events_report_#{DateTime.now.strftime("%F")}.csv" }
    end
  end
def index @application_process_options_handler = ApplicationProcessOptionsHandler . find ( 1 ) @events = Event . all @new_users = User . all . created_last_30_days @total_organizers = Event . all . total_organizers @countries = Event . all . pluck ( :country ) . compact @countries_statistics = CountriesStatistics . new ( @events ) . to_json @country_rank = CountriesStatistics . new ( @events ) . country_rank @categorized_events = { "Unapproved events" => Event . unapproved . upcoming . order ( :deadline ) , "Approved events" => Event . approved . upcoming . order ( :deadline ) , "Past approved events" => Event . approved . past . order ( deadline : :desc ) . active , "Past unapproved events" => Event . unapproved . past . order ( :deadline ) . active } @approved_events_deadline = { "Open deadline:" => Event . approved . upcoming . open . order ( :deadline ) , "Closed deadline:" => Event . approved . upcoming . closed . order ( :deadline ) } respond_to do | format | format . html format . csv { send_data ReportExporter . events_report , filename : "events_report_#{DateTime.now.strftime("%F")}.csv" } end end
Admin page view with all submitted events and admin statistics:
Admin page view with all submitted events and admin statistics :