<commit_before>module Genealogy
  module ComplexQueryMethods
    extend ActiveSupport::Concern
    include Constants

    def least_common_ancestor(other_person)
      raise ArgumentError, "argument must be an instance of the #{gclass} class" unless other_person.is_a? gclass
      self_parent_ids = [self.id]
      other_parent_ids = [other_person.id]

      generation_count = 1

      self_ancestor_record_ids = [self.id]
      other_ancestor_record_ids = [other_person.id]

      while self_parent_ids.length > 0 || other_parent_ids.length > 0
        self_next_gen = gclass.where(id: self_parent_ids).pluck(:father_id, :mother_id).flatten.compact
        other_next_gen = gclass.where(id: other_parent_ids).pluck(:father_id, :mother_id).flatten.compact

        self_ancestor_record_ids += self_next_gen
        self_parent_ids = self_next_gen

        other_ancestor_record_ids += other_next_gen
        other_parent_ids = other_next_gen

        if (self_ancestor_record_ids & other_ancestor_record_ids).length > 0
          return gclass.where(id: (self_ancestor_record_ids & other_ancestor_record_ids))
        else
          generation_count += 1
        end
      end
      gclass.where(id: nil)
    end


  end
end<commit_msg>removed random new line<commit_after>module Genealogy
  module ComplexQueryMethods
    extend ActiveSupport::Concern
    include Constants

    def least_common_ancestor(other_person)
      raise ArgumentError, "argument must be an instance of the #{gclass} class" unless other_person.is_a? gclass
      self_parent_ids = [self.id]
      other_parent_ids = [other_person.id]

      generation_count = 1

      self_ancestor_record_ids = [self.id]
      other_ancestor_record_ids = [other_person.id]

      while self_parent_ids.length > 0 || other_parent_ids.length > 0
        self_next_gen = gclass.where(id: self_parent_ids).pluck(:father_id, :mother_id).flatten.compact
        other_next_gen = gclass.where(id: other_parent_ids).pluck(:father_id, :mother_id).flatten.compact

        self_ancestor_record_ids += self_next_gen
        self_parent_ids = self_next_gen

        other_ancestor_record_ids += other_next_gen
        other_parent_ids = other_next_gen

        if (self_ancestor_record_ids & other_ancestor_record_ids).length > 0
          return gclass.where(id: (self_ancestor_record_ids & other_ancestor_record_ids))
        else
          generation_count += 1
        end
      end
      gclass.where(id: nil)
    end

  end
end
{'fraction_non_alphanumeric': 0.07082494969818913, 'fraction_numerical': 0.004024144869215292, 'mean_word_length': 3.369068541300527, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5885323', 'n_tokens_mistral': 831, 'n_tokens_neox': 798, 'n_words': 148}