lib/trait_bank/stats.rb
# XXX: this isn't very performant, but the assumption is that that the filtering case is rare
this isn't very performant, but the assumption is that that the filtering case is rare
this isn ' t very performant but the assumption is that that the filtering case is rare
def filter_identical_count_ancestors(results, limit)
        grouped_results = results.group_by { |result| result[:count] }
        objs_to_filter = []
        grouped_results.each do |_, results_for_count|
          next if results_for_count.length == 1
          results_for_count.each do |result|
            results_for_count.each do |other_result|
              next if result == other_result
              obj = result[:obj][:uri]
              other_obj = other_result[:obj][:uri]
              objs_to_filter << obj if TraitBank::Term.term_descendant_of_other?(other_obj, obj)
            end
          end
        end
        filtered = results.reject { |r| objs_to_filter.include?(r[:obj][:uri]) }
        filtered[0..limit]
      end
def filter_identical_count_ancestors ( results , limit ) grouped_results = results . group_by { | result | result [ :count ] } objs_to_filter = [ ] grouped_results . each do | _ , results_for_count | next if results_for_count . length == 1 results_for_count . each do | result | results_for_count . each do | other_result | next if result == other_result obj = result [ :obj ] [ :uri ] other_obj = other_result [ :obj ] [ :uri ] objs_to_filter << obj if TraitBank :: Term . term_descendant_of_other? ( other_obj , obj ) end end end filtered = results . reject { | r | objs_to_filter . include? ( r [ :obj ] [ :uri ] ) } filtered [ 0 .. limit ] end
XXX: this isn't very performant, but the assumption is that that the filtering case is rare
XXX : this isn ' t very performant but the assumption is that that the filtering case is rare
results
<not_specific>
limit
<not_specific>