Revision 1022:f2ec92061fca

View differences:

app/controllers/activities_controller.rb
44 44
    if !@institution_name.blank?
45 45
      events = events.select do |e|
46 46
        e.respond_to?(:event_author) and e.event_author and
47
	  e.event_author.respond_to?(:ssamr_user_detail) and
48
          !e.event_author.ssamr_user_detail.nil? and
47 49
          e.event_author.ssamr_user_detail.institution_name == @institution_name
48 50
      end
49 51
      if events.empty?
app/helpers/activities_helper.rb
13 13
  end
14 14

  
15 15
  def busy_institutions(events, count)
16
    authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact
17
    institutions = authors.map { |a| a.ssamr_user_detail.institution_name }
16
    authors = events.map do |e|
17
      e.event_author unless !e.respond_to?(:event_author) 
18
    end.compact
19
    institutions = authors.map do |a|
20
      if a.respond_to?(:ssamr_user_detail) and !a.ssamr_user_detail.nil?
21
        a.ssamr_user_detail.institution_name
22
      end
23
    end
18 24
    insthash = institutions.compact.sort.group_by { |i| i }
19 25
    insthash = insthash.merge(insthash) { |k,v| v.length }
20 26
    threshold = insthash.values.sort.last(count).first

Also available in: Unified diff