app/controllers/versions_controller.rb
def paginate_list(id, user_id, item_type, event, _datetime)
    # Set up the search criteria
    criteria = ''
    criteria += "id = #{id} AND " if id && id.to_i > 0
    if current_user_role? == 'Super-Administrator'
      criteria += "whodunnit = #{user_id} AND " if user_id && user_id.to_i > 0
    end
    criteria += "whodunnit = #{current_user.try(:id)} AND " if current_user.try(:id) && current_user.try(:id).to_i > 0
    criteria += "item_type = '#{item_type}' AND " if item_type && !(item_type.eql? 'Any')
    criteria += "event = '#{event}' AND " if event && !(event.eql? 'Any')
    criteria += "created_at >= '#{time_to_string(params[:start_time])}' AND "
    criteria += "created_at <= '#{time_to_string(params[:end_time])}' AND "

    if current_role == 'Instructor' || current_role == 'Administrator'

    end

    # Remove the last ' AND '
    criteria = criteria[0..-5]

    versions = Version.page(params[:page]).order('id').per_page(25).where(criteria)
    versions
  end
# For filtering the versions list with proper search and pagination.
For filtering the versions list with proper search and pagination.
For filtering the versions list with proper search and pagination .
def paginate_list(id, user_id, item_type, event, _datetime)
    criteria = ''
    criteria += "id = #{id} AND " if id && id.to_i > 0
    if current_user_role? == 'Super-Administrator'
      criteria += "whodunnit = #{user_id} AND " if user_id && user_id.to_i > 0
    end
    criteria += "whodunnit = #{current_user.try(:id)} AND " if current_user.try(:id) && current_user.try(:id).to_i > 0
    criteria += "item_type = '#{item_type}' AND " if item_type && !(item_type.eql? 'Any')
    criteria += "event = '#{event}' AND " if event && !(event.eql? 'Any')
    criteria += "created_at >= '#{time_to_string(params[:start_time])}' AND "
    criteria += "created_at <= '#{time_to_string(params[:end_time])}' AND "
    if current_role == 'Instructor' || current_role == 'Administrator'
    end
    criteria = criteria[0..-5]
    versions = Version.page(params[:page]).order('id').per_page(25).where(criteria)
    versions
  end
def paginate_list ( id , user_id , item_type , event , _datetime ) criteria = '' criteria += "id = #{id} AND " if id && id . to_i > 0 if current_user_role? == 'Super-Administrator' criteria += "whodunnit = #{user_id} AND " if user_id && user_id . to_i > 0 end criteria += "whodunnit = #{current_user.try(:id)} AND " if current_user . try ( :id ) && current_user . try ( :id ) . to_i > 0 criteria += "item_type = '#{item_type}' AND " if item_type && ! ( item_type . eql? 'Any' ) criteria += "event = '#{event}' AND " if event && ! ( event . eql? 'Any' ) criteria += "created_at >= '#{time_to_string(params[:start_time])}' AND " criteria += "created_at <= '#{time_to_string(params[:end_time])}' AND " if current_role == 'Instructor' || current_role == 'Administrator' end criteria = criteria [ 0 .. - 5 ] versions = Version . page ( params [ :page ] ) . order ( 'id' ) . per_page ( 25 ) . where ( criteria ) versions end
For filtering the versions list with proper search and pagination.
For filtering the versions list with proper search and pagination .
# Set up the search criteria # Remove the last ' AND '
id
user_id
item_type
event
_datetime