<commit_before>class Project < ActiveRecord::Base
  acts_as_paranoid

  has_many :project_answers
  has_many :staff_projects
  has_many :staff, through: :staff_projects
  has_many :services, foreign_key: 'project_id', class_name: 'OrderItem'

  has_many :alerts, primary_key: 'id', foreign_key: 'project_id', class_name: 'Alert'
  has_many :latest_alerts, through: :services, class_name: 'Alert'

  has_many :approvals
  has_many :approvers, through: :approvals, source: :staff

  has_one :project_detail

  accepts_nested_attributes_for :project_answers

  scope :main_inclusions, -> { includes(:staff).includes(:project_answers).includes(:services) }

  enum status: { ok: 0, warning: 1, critical: 2, unknown: 3, pending: 4 }

  def order_history
    history = Order.where(id: OrderItem.where(project_id: id).select(:order_id)).map do |order|
      order_json = order.as_json
      order_json[:item_count] = order.item_count_for_project_id(id)
      order_json
    end
    history
  end

  def domain
    'companyapp1.clouddealer.com/'
  end

  def url
    'http://companyapp1.clouddealer.com'
  end

  def state
    case problem_count
    when 0
      '0 Problems'
    when 1
      '1 Problem'<commit_msg>simplified logic<commit_after>class Project < ActiveRecord::Base
  acts_as_paranoid

  has_many :project_answers
  has_many :staff_projects
  has_many :staff, through: :staff_projects
  has_many :services, foreign_key: 'project_id', class_name: 'OrderItem'

  has_many :alerts, primary_key: 'id', foreign_key: 'project_id', class_name: 'Alert'
  has_many :latest_alerts, through: :services, class_name: 'Alert'

  has_many :approvals
  has_many :approvers, through: :approvals, source: :staff

  has_one :project_detail

  accepts_nested_attributes_for :project_answers

  scope :main_inclusions, -> { includes(:staff).includes(:project_answers).includes(:services) }

  enum status: { ok: 0, warning: 1, critical: 2, unknown: 3, pending: 4 }

  def order_history
    history = Order.where(id: OrderItem.where(project_id: id).select(:order_id)).map do |order|
      order_json = order.as_json
      order_json[:item_count] = order.item_count_for_project_id(id)
      order_json
    end
    history
  end

  def domain
    'companyapp1.clouddealer.com/'
  end

  def url
    'http://companyapp1.clouddealer.com'
  end

  def state
    if problem_count == 1
      '1 Problem'
{'fraction_non_alphanumeric': 0.10247795044099119, 'fraction_numerical': 0.008399832003359933, 'mean_word_length': 4.316964285714286, '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': '4500355', 'n_tokens_mistral': 835, 'n_tokens_neox': 792, 'n_words': 185}