<commit_before>class ClaimsController < ApplicationController
  before_filter :load_user
  load_and_authorize_resource

  def index
    if !@user.is_admin_or_staff?
      collection = @user.claims
    elsif params[:user_id]
      collection = Claim.where(orcid: @user.uid)
      @my_claim_count = collection.count
    else
      collection = Claim
      @my_claim_count = Claim.where(orcid: @user.uid).count
    end
    collection = collection.query(params[:query]) if params[:query]
    if params[:source].present?
      collection = collection.where(source_id: params[:source])
      @source = collection.group(:source_id).count.first
    end
    if params[:state].present?
      collection = collection.where(state: params[:state])
      @state = collection.group(:state).count.first
    end
    @sources = collection.where.not(source_id: nil).group(:source_id).count
    @states = collection.where.not(state: nil).group(:state).count
    @claims = collection.order_by_date.paginate(:page => params[:page])
    @page = params[:page] || 1
  end

  protected

  def load_user
    if user_signed_in?
      @user = current_user
    else
      fail CanCan::AccessDenied.new("Please sign in first.", :read, User)
    end
  end
end<commit_msg>use correct value for user_id<commit_after>class ClaimsController < ApplicationController
  before_filter :load_user
  load_and_authorize_resource

  def index
    if !@user.is_admin_or_staff?
      collection = @user.claims
    elsif params[:user_id]
      collection = Claim.where(orcid: params[:user_id])
      @my_claim_count = collection.count
    else
      collection = Claim
      @my_claim_count = Claim.where(orcid: params[:user_id]).count
    end
    collection = collection.query(params[:query]) if params[:query]
    if params[:source].present?
      collection = collection.where(source_id: params[:source])
      @source = collection.group(:source_id).count.first
    end
    if params[:state].present?
      collection = collection.where(state: params[:state])
      @state = collection.group(:state).count.first
    end
    @sources = collection.where.not(source_id: nil).group(:source_id).count
    @states = collection.where.not(state: nil).group(:state).count
    @claims = collection.order_by_date.paginate(:page => params[:page])
    @page = params[:page] || 1
  end

  protected

  def load_user
    if user_signed_in?
      @user = current_user
    else
      fail CanCan::AccessDenied.new("Please sign in first.", :read, User)
    end
  end
end
{'fraction_non_alphanumeric': 0.11562998405103668, 'fraction_numerical': 0.0007974481658692185, 'mean_word_length': 3.586837294332724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1768911', 'n_tokens_mistral': 773, 'n_tokens_neox': 750, 'n_words': 157}