Sha256: f17a0e2328810b955e41aa7381373d207aa4376ce9c7f45511e66cf15ea7d699

Contents?: true

Size: 591 Bytes

Versions: 7

Compression:

Stored size: 591 Bytes

Contents

module RelationshipsHelper

  def relationships_struct(person)
    single = []
    grouped = []
    counts = person.relationships.group(:relation_id).count
    counts.each do |id, count|
      if count > 5
        grouped << {:relation => id, :count => count}
      else
        single << id # Run person.in_relationships(relationships)
      end
    end

    {
      :starred => person.relationships.starred,
      :single => single,
      :grouped => grouped
    }
  end

  def relationship_counts_for(person)
    person.relationships.includes(:relation).group(:relation).count
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
artfully_ose-1.2.0 app/helpers/relationships_helper.rb
artfully_ose-1.2.0.beta.1 app/helpers/relationships_helper.rb
artfully_ose-1.2.0.alpha.2 app/helpers/relationships_helper.rb
artfully_ose-1.2.0.alpha.1 app/helpers/relationships_helper.rb
artfully_ose-1.2.0.pre.27 app/helpers/relationships_helper.rb
artfully_ose-1.2.0.pre.26 app/helpers/relationships_helper.rb
artfully_ose-1.2.0.pre.24 app/helpers/relationships_helper.rb