<commit_before>class ApplicationController < ActionController::Base
  layout :themed_layout
  protect_from_forgery

  helper_method :current_user, :current_domain, :current_project, :logged_in?
  helper_method :themed, :try_translation

  before_filter :set_activity_user

  def themed_layout(layout = :application)
    "themes/#{current_theme}/#{layout}"
  end

  private

  def current_domain
    current_user.try(:domain)
  end

  def current_project
    @project ||= resource.respond_to?(:context) && resource.context.try(:resource).is_a?(Project) && resource.context.resource
  end<commit_msg>Fix bug in ApplicationController#current_project<commit_after>class ApplicationController < ActionController::Base
  layout :themed_layout
  protect_from_forgery

  helper_method :current_user, :current_domain, :current_project, :logged_in?
  helper_method :themed, :try_translation

  before_filter :set_activity_user

  def themed_layout(layout = :application)
    "themes/#{current_theme}/#{layout}"
  end

  private

  def current_domain
    current_user.try(:domain)
  end

  def current_project
    @current_project ||= begin
      project = if resource.is_a?(Project)
        resource
      elsif resource.respond_to?(:context) && resource.context.try(:resource).is_a?(Project)
        resource.context.resource
      end
      !!project.try(:new_record?) ? nil : project
    end
  end
{'fraction_non_alphanumeric': 0.09712230215827339, 'fraction_numerical': 0.0, 'mean_word_length': 4.820083682008368, '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': '3857367', 'n_tokens_mistral': 424, 'n_tokens_neox': 414, 'n_words': 79}