Class: EducodeSales::UserBehaviorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/educode_sales/user_behaviors_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_admin, #authenticate_request, #current_user, #filter, #is_commissioner_above?, #paginate, #render_failure, #render_success, #subject_members, #subject_staffs, #subject_url

Methods included from ApplicationHelper

#add_businesses_score, #base_url, #collection_amount_score, #completion_rate, #current?, #disk_filename, #get_businesses_chart, #handled_data, #handled_time_data, #handled_time_data_accurate, #relative_path, #signed_amount_score, #storage_path, #url_to_avatar, #visits_score

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/educode_sales/user_behaviors_controller.rb', line 5

def index
  respond_to do |format|
    format.html do
    end
    format.json do
      if params[:sort].present? && params[:sort][:field]
        if params[:sort][:field] == 'name'
          @data = LoginHistory.joins(staff: :user).order("users.lastname #{params[:sort][:order]}")
        else
          @data = LoginHistory.order("#{params[:sort][:field]} #{params[:sort][:order]}")
        end
      else
        @data = LoginHistory.order(created_at: :desc)
      end
      @data = @data.page(params[:page]).per(params[:limit])
    end
  end
end