<commit_before>class User < ActiveRecord::Base
  has_many :submissions
  def self.create_with_omniauth(auth)
    create! do |user|
      user.provider = auth['provider']
      user.uid = auth['uid']
      if auth['info']
         user.name = auth['info']['name'] || ""
      end
    end
  end

  def self.has_submissions?(user)
    Submission.where(user_id: user.id).any?
  end

  def self.total_points(user)
    if Submission.where(user_id: user.id).length > 0
      Challenge.find(Submission
                      .where(user_id: user.id)
                      .pluck(:challenge_id)
                     ).map(&:points)
                      .reduce(:+)
    else
      nil
    end
  end

  def self.total_submissions(user)
    Submission.where(user_id: user.id).length
  end

  def self.last_submission(user)
    return if !User.has_submissions?(user)
    Submission.where(user_id: user.id)
              .last
              .challenge_id
  end

  def self.hunt_complete?(user)
    Challenge.final_challenge_id == User.last_submission(user)
  end

  def self.next_challenge(user)
    if Submission.where(user_id: user.id).length > 0
      Challenge.find(Submission
                .where(user_id: user.id)
                .last
                .challenge_id)
                .next
    else
      nil
    end
  end
end<commit_msg>use new has_submissions? method to drop the if/else and just return if no submissions yet<commit_after>class User < ActiveRecord::Base
  has_many :submissions
  def self.create_with_omniauth(auth)
    create! do |user|
      user.provider = auth['provider']
      user.uid = auth['uid']
      if auth['info']
         user.name = auth['info']['name'] || ""
      end
    end
  end

  def self.has_submissions?(user)
    Submission.where(user_id: user.id).any?
  end

  def self.total_points(user)
    return if !User.has_submissions?(user)
    Challenge.find(Submission
                      .where(user_id: user.id)
                      .pluck(:challenge_id)
                     ).map(&:points)
                      .reduce(:+)
  end

  def self.total_submissions(user)
    Submission.where(user_id: user.id).length
  end

  def self.last_submission(user)
    return if !User.has_submissions?(user)
    Submission.where(user_id: user.id)
              .last
              .challenge_id
  end

  def self.hunt_complete?(user)
    Challenge.final_challenge_id == User.last_submission(user)
  end

  def self.next_challenge(user)
    return if !User.has_submissions?(user)
    Challenge.find(Submission
                .where(user_id: user.id)
                .last
                .challenge_id)
                .next
  end
end
{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.0007518796992481203, 'mean_word_length': 2.0446224256292904, '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': '5066353', 'n_tokens_mistral': 885, 'n_tokens_neox': 832, 'n_words': 163}