def index
      page          = params.fetch(:page, 1).to_i
      per_page      = ModelsAuditor.config.records_per_page
      paginate_info = {page: page, per_page: per_page}.tap do |info|
        info.merge!(total_entries: (page * per_page + per_page * 10)) if ModelsAuditor.config.fake_total_count
      end

      @collection =
        ModelsAuditor::AuditRequest.includes(:records).all
          .order("#{ModelsAuditor::AuditRequest.table_name}.created_at DESC")
          .paginate(paginate_info)

      @collection = apply_filters(@collection, params[:filters])

      respond_to do |f|
        if ModelsAuditor.config.respond_to_json_enabled
          formatter = ModelsAuditor.config.log_output_formatter.constantize.new(@collection)

          f.json {
            render json: {
              ModelsAuditor.config.json_response_data_key => formatter.as_json,
              ModelsAuditor.config.json_response_meta_key => {
                per_page: paginate_info[:per_page]      || @collection.per_page,
                total:    paginate_info[:total_entries] || @collection.total_entries,
                sort_by:  @collection.order_info
              }
            }
          }
        end
        if ModelsAuditor.config.respond_to_html_enabled
          f.html
        end
      end
    end
def index
      page          = params.fetch(:page, 1).to_i
      per_page      = ModelsAuditor.config.records_per_page
      paginate_info = {page: page, per_page: per_page}.tap do |info|
        info.merge!(total_entries: (page * per_page + per_page * 10)) if ModelsAuditor.config.fake_total_count
      end

      @collection =
        ModelsAuditor::AuditRequest.includes(:records).all
          .order("#{ModelsAuditor::AuditRequest.table_name}.created_at DESC")
          .paginate(paginate_info)

      @collection = apply_filters(@collection, params[:filters])

      respond_to do |f|
        if ModelsAuditor.config.respond_to_json_enabled
          formatter = ModelsAuditor.config.log_output_formatter.constantize.new(@collection)

          f.json {
            render json: {
              ModelsAuditor.config.json_response_data_key => formatter.as_json,
              ModelsAuditor.config.json_response_meta_key => {
                per_page: paginate_info[:per_page]      || @collection.per_page,
                total:    paginate_info[:total_entries] || @collection.total_entries,
                sort_by:  @collection.order_info
              }
            }
          }
        end
        if ModelsAuditor.config.respond_to_html_enabled
          f.html
        end
      end
    end
GET /pages.json