<commit_before>class Grant < ActiveRecord::Base
  COMPONENTS = [:people].freeze

  before_save :set_application_date

  # rubocop:disable Rails/HasAndBelongsToMany
  has_and_belongs_to_many :reason_types
  has_and_belongs_to_many :coverage_types

  default_scope -> { order(application_date: :desc) }

  belongs_to :user
  belongs_to :subsidy_type
  belongs_to :status, class_name: "GrantStatus", foreign_key: :grant_status_id
  belongs_to :residence
  belongs_to :previous_residence, class_name: "Residence", foreign_key: :previous_residence_id
  belongs_to :last_month_budget, class_name: "Budget"
  belongs_to :current_month_budget, class_name: "Budget"
  belongs_to :next_month_budget, class_name: "Budget"

  has_many :people, autosave: true
  has_many :other_payments
  has_many :payees
  has_many :comments

  delegate :agency, to: :user

  accepts_nested_attributes_for(*COMPONENTS, reject_if: :all_blank, allow_destroy: true)

  def status_name
    raise "Grant can not have blank grant status" if status.blank?
    status.description
  end

  def set_application_date
    self.application_date = Time.zone.today
  end

  def primary_applicant
    people.first
  end

  def primary_applicant_name
    primary_applicant.full_name
  end

  def agency_name
    user.agency.name
  end

  def case_worker_name
    user.full_name
  end
end<commit_msg>agency is delegated for user<commit_after>class Grant < ActiveRecord::Base
  COMPONENTS = [:people].freeze

  before_save :set_application_date

  # rubocop:disable Rails/HasAndBelongsToMany
  has_and_belongs_to_many :reason_types
  has_and_belongs_to_many :coverage_types

  default_scope -> { order(application_date: :desc) }

  belongs_to :user
  belongs_to :subsidy_type
  belongs_to :status, class_name: "GrantStatus", foreign_key: :grant_status_id
  belongs_to :residence
  belongs_to :previous_residence, class_name: "Residence", foreign_key: :previous_residence_id
  belongs_to :last_month_budget, class_name: "Budget"
  belongs_to :current_month_budget, class_name: "Budget"
  belongs_to :next_month_budget, class_name: "Budget"

  has_many :people, autosave: true
  has_many :other_payments
  has_many :payees
  has_many :comments

  delegate :agency, to: :user

  accepts_nested_attributes_for(*COMPONENTS, reject_if: :all_blank, allow_destroy: true)

  def status_name
    raise "Grant can not have blank grant status" if status.blank?
    status.description
  end

  def set_application_date
    self.application_date = Time.zone.today
  end

  def primary_applicant
    people.first
  end

  def primary_applicant_name
    primary_applicant.full_name
  end

  def agency_name
    agency.name
  end

  def case_worker_name
    user.full_name
  end
end
{'fraction_non_alphanumeric': 0.06659308314937454, 'fraction_numerical': 0.0, 'mean_word_length': 4.988986784140969, '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': '4780584', 'n_tokens_mistral': 968, 'n_tokens_neox': 929, 'n_words': 205}