<commit_before>class ChallengeMonthController < ApplicationController
  
  #To get the challenge_month and challenge_league.
  helper_method :challenge_month, :challenge_league, :submission
  
  def result
    @submission = Submission.new
    @submission.user_id = session[:user_id]
    @submission.submission_code = params[:script].read
    @submission.month = challenge_month
    @submission.league = challenge_league
    @submission.save
    render template:'layouts/result'
  end
  
  def submission
    return @submission
  end
  
  def challenge_league
    request.env['HTTP_REFERER'].match(controller_name+'/(\w+)')[1]
  end
  
  def challenge_month
    controller_name
  end
  
  def submission_json
    render json: Submission.group(:user_id).having('max(created_at)').select(:submission_code).to_a
  end
end<commit_msg>Added where clause to the submission json method.<commit_after>class ChallengeMonthController < ApplicationController
  
  #To get the challenge_month and challenge_league.
  helper_method :challenge_month, :challenge_league, :submission
  
  def result
    @submission = Submission.new
    @submission.user_id = session[:user_id]
    @submission.submission_code = params[:script].read
    @submission.month = challenge_month
    @submission.league = challenge_league
    @submission.save
    render template:'layouts/result'
  end
  
  def submission
    return @submission
  end
  
  def challenge_league
    request.env['HTTP_REFERER'].match(controller_name+'/(\w+)')[1]
  end
  
  def challenge_month
    controller_name
  end
  
  def submission_json
    render json: Submission.where(month: challenge_month, league: challenge_league).group(:user_id).having('max(created_at)').select(:submission_code).to_a
  end
end
{'fraction_non_alphanumeric': 0.08971428571428572, 'fraction_numerical': 0.001142857142857143, 'mean_word_length': 4.3547400611620795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4220219', 'n_tokens_mistral': 551, 'n_tokens_neox': 527, 'n_words': 107}