<commit_before>class TriggersController < ApplicationController
  before_filter :if_not_signed_in
  before_action :set_trigger, only: [:show, :edit, :update, :destroy]

  # GET /triggers
  # GET /triggers.json
  def index
    @triggers = Trigger.where(:userid => current_user.id).all
    @page_title = "Triggers"
    @page_new = new_trigger_path
  end

  # GET /triggers/1
  # GET /triggers/1.json
  def show
    if current_user.id == @trigger.userid
      @page_edit = edit_trigger_path(@trigger) 
    else
      link_url = "/profile?userid=" + @trigger.userid.to_s
      the_link = link_to User.where(:id => @trigger.userid).first.firstname + " " + User.where(:id => @trigger.userid).first.lastname, link_url
      @page_author = the_link.html_safe
    end
    @no_hide_page = false
    if hide_page && @trigger.userid != current_user.id
      respond_to do |format|
        format.html { redirect_to triggers_path }
        format.json { head :no_content }
      end
    else 
      @comment = Comment.new
      @support = Support.new
      @comments = Comment.where(:commented_on => @trigger.id).all
      @no_hide_page = true
      @page_title = @trigger.name
    end 
  end

  def comment
    @comment = Comment.create!(:comment_type => params[:comment][:comment_type], :commented_on => params[:comment][:commented_on], :comment_by => params[:comment][:comment_by], :comment => params[:comment][:comment], :comment => params[:comment][:visibility])
    respond_to do |format|
        format.html { redirect_to trigger_path(params[:comment][:commented_on]), notice: 'Comment was successfully created.' }
        format.json { render :show, status: :created, location: Trigger.find(params[:comment][:commented_on]) }
    end
  end 

  def support
    if !params[:support].nil? && !params[:support][:userid].empty? && !params[:support][:support_type].empty? && !params[:support][:support_id].empty?
      params[:userid] = params[:support][:userid]
      params[:support_type] = params[:support][:support_type]
      params[:support_id] = params[:support][:support_id]
    end
    
    support_id = params[:support_id].to_i

    if Support.where(userid: params[:userid], support_type: params[:support_type]).exists?<commit_msg>Fixed issue with visibility<commit_after>class TriggersController < ApplicationController
  before_filter :if_not_signed_in
  before_action :set_trigger, only: [:show, :edit, :update, :destroy]

  # GET /triggers
  # GET /triggers.json
  def index
    @triggers = Trigger.where(:userid => current_user.id).all
    @page_title = "Triggers"
    @page_new = new_trigger_path
  end

  # GET /triggers/1
  # GET /triggers/1.json
  def show
    if current_user.id == @trigger.userid
      @page_edit = edit_trigger_path(@trigger) 
    else
      link_url = "/profile?userid=" + @trigger.userid.to_s
      the_link = link_to User.where(:id => @trigger.userid).first.firstname + " " + User.where(:id => @trigger.userid).first.lastname, link_url
      @page_author = the_link.html_safe
    end
    @no_hide_page = false
    if hide_page && @trigger.userid != current_user.id
      respond_to do |format|
        format.html { redirect_to triggers_path }
        format.json { head :no_content }
      end
    else 
      @comment = Comment.new
      @support = Support.new
      @comments = Comment.where(:commented_on => @trigger.id).all
      @no_hide_page = true
      @page_title = @trigger.name
    end 
  end

  def comment
    @comment = Comment.create!(:comment_type => params[:comment][:comment_type], :commented_on => params[:comment][:commented_on], :comment_by => params[:comment][:comment_by], :comment => params[:comment][:comment], :visibility => params[:comment][:visibility])
    respond_to do |format|
        format.html { redirect_to trigger_path(params[:comment][:commented_on]), notice: 'Comment was successfully created.' }
        format.json { render :show, status: :created, location: Trigger.find(params[:comment][:commented_on]) }
    end
  end 

  def support
    if !params[:support].nil? && !params[:support][:userid].empty? && !params[:support][:support_type].empty? && !params[:support][:support_id].empty?
      params[:userid] = params[:support][:userid]
      params[:support_type] = params[:support][:support_type]
      params[:support_id] = params[:support][:support_id]
    end
    
    support_id = params[:support_id].to_i

    if Support.where(userid: params[:userid], support_type: params[:support_type]).exists?
{'fraction_non_alphanumeric': 0.14027250390886756, 'fraction_numerical': 0.0008934554389099843, 'mean_word_length': 3.888646288209607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6524875', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1413, 'n_words': 272}