app/controllers/admin_controller.rb
def topic_search

    # search for user, if [one] found, we'll give details on that person
    # if more than one found, we'll list them
    users = User.user_search(params[:q])

    if users.size == 0 # not a user search, so look for topics
      @topics = Topic.admin_search(params[:q]).page params[:page]
      template = 'tickets'

      @tracker.event(category: "Admin Search", action: "Topic Search", label: params[:q])

    else
      if users.size == 1
        @user = users.first
        @topics = Topic.admin_search(params[:q]).page params[:page]
        @topic = Topic.where(user_id: @user.id).first unless @user.nil?
        template = 'tickets'

        @tracker.event(category: "Admin Search", action: "User Search", label: params[:q])
        @tracker.event(category: "Agent: #{current_user.name}", action: "Viewed User Profile", label: @user.name)

      else
        @users = users.page params[:page]
        template = 'users'
        @tracker.event(category: "Admin Search", action: "User Search", label: params[:q])
      end
    end

    respond_to do |format|
      format.html {
        render template
      }
      format.js {
        render template
      }
    end

  end
# simple search tickets by # and user
simple search tickets by # and user
simple search tickets by # and user
def topic_search
    users = User.user_search(params[:q])
    if users.size == 0 
      @topics = Topic.admin_search(params[:q]).page params[:page]
      template = 'tickets'
      @tracker.event(category: "Admin Search", action: "Topic Search", label: params[:q])
    else
      if users.size == 1
        @user = users.first
        @topics = Topic.admin_search(params[:q]).page params[:page]
        @topic = Topic.where(user_id: @user.id).first unless @user.nil?
        template = 'tickets'
        @tracker.event(category: "Admin Search", action: "User Search", label: params[:q])
        @tracker.event(category: "Agent: #{current_user.name}", action: "Viewed User Profile", label: @user.name)
      else
        @users = users.page params[:page]
        template = 'users'
        @tracker.event(category: "Admin Search", action: "User Search", label: params[:q])
      end
    end
    respond_to do |format|
      format.html {
        render template
      }
      format.js {
        render template
      }
    end
  end
def topic_search users = User . user_search ( params [ :q ] ) if users . size == 0 @topics = Topic . admin_search ( params [ :q ] ) . page params [ :page ] template = 'tickets' @tracker . event ( category : "Admin Search" , action : "Topic Search" , label : params [ :q ] ) else if users . size == 1 @user = users . first @topics = Topic . admin_search ( params [ :q ] ) . page params [ :page ] @topic = Topic . where ( user_id : @user . id ) . first unless @user . nil? template = 'tickets' @tracker . event ( category : "Admin Search" , action : "User Search" , label : params [ :q ] ) @tracker . event ( category : "Agent: #{current_user.name}" , action : "Viewed User Profile" , label : @user . name ) else @users = users . page params [ :page ] template = 'users' @tracker . event ( category : "Admin Search" , action : "User Search" , label : params [ :q ] ) end end respond_to do | format | format . html { render template } format . js { render template } end end
simple search tickets by # and user
simple search tickets by # and user
# search for user, if [one] found, we'll give details on that person # if more than one found, we'll list them # not a user search, so look for topics