<commit_before>class Project
  include Mongoid::Document
  include Rally::ParsingHelpers
  extend Rally::ParsingHelperClassMethods

  class << self
    def rally_uri
      "/project.js"
    end
  end

  field :name
  field :rally_uri
  field :created_on
  field :description
  field :notes
  field :state

  referenced_in :parent, :class_name => "Project"
  references_many :children, :class_name => "Project"
  references_many :iterations  
  references_many :stories
  embeds_one :revision_parser
  
  def refresh hash_values=nil
    @rally_hash = hash_values if hash_values
    from_rally :name
    from_rally :description
    from_rally :state
    from_rally :notes

    self.save

  end
  
  #must be called after refresh, or with has_values passed in
  def associate hash_values=nil
    @rally_hash = hash_values || RallyAPI.get(self)
    #TODO: associate with user when users are supported<commit_msg>added ancestors to project<commit_after>class Project
  include Mongoid::Document
  include Rally::ParsingHelpers
  extend Rally::ParsingHelperClassMethods

  class << self
    def rally_uri
      "/project.js"
    end
  end

  field :name
  field :rally_uri
  field :created_on
  field :description
  field :notes
  field :state

  referenced_in :parent, :class_name => "Project", :inverse_of => :children
  references_many :children, :class_name => "Project", :inverse_of => :parent
  references_many :iterations  
  references_many :stories
  embeds_one :revision_parser

  def ancestors
    if parent
      a = parent.ancestors << self
      return a
    else
      return [self]
    end
  end

  
  def refresh hash_values=nil
    @rally_hash = hash_values if hash_values
    from_rally :name
    from_rally :description
    from_rally :state
    from_rally :notes

    self.save

  end
  
  #must be called after refresh, or with has_values passed in
  def associate hash_values=nil
    @rally_hash = hash_values || RallyAPI.get(self)
    #TODO: associate with user when users are supported
{'fraction_non_alphanumeric': 0.0658682634730539, 'fraction_numerical': 0.0, 'mean_word_length': 3.525959367945824, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1301278', 'n_tokens_mistral': 636, 'n_tokens_neox': 629, 'n_words': 184}