+ # Get user role
+ if @user.administrator?
+ @user_role = "administrator"
+ else
+ @user_role = "moderator"
+ end
+
+ # If search
+ if params[:search_by_user]
+ @find_user = User.find_by_display_name(params[:search_by_user])
+ if @find_user
+ @issues = Issue.where(reported_user_id: @find_user.id, issue_type: @user_role).order(:status)
+ else
+ @issues = Issue.where(issue_type: @user_role).order(:status)
+ notice = t('issues.index.search.user_not_found')
+ end
+
+ if @find_user !=nil and @issues.first == nil
+ @issues = Issue.where(issue_type: @user_role).order(:status)
+ notice = t('issues.index.search.issues_not_found')
+ end
+
+ if notice
+ redirect_to issues_path, notice: notice
+ end
+
+ else
+ @issues = Issue.where(issue_type: @user_role).order(:status)
+ end