change #count to #size in notifications_helper to reduce queries

This commit is contained in:
Fabián Rodríguez 2013-01-15 01:10:30 -02:00
parent d4d3bf8af6
commit 8b4aab0780

View file

@ -3,7 +3,7 @@ module NotificationsHelper
def object_link(note, actors) def object_link(note, actors)
target_type = note.popup_translation_key target_type = note.popup_translation_key
actors_count = note.actors.count actors_count = note.actors.size
if note.instance_of?(Notifications::Mentioned) if note.instance_of?(Notifications::Mentioned)
if post = note.linked_object if post = note.linked_object
@ -29,7 +29,7 @@ module NotificationsHelper
def notification_people_link(note, people=nil) def notification_people_link(note, people=nil)
actors =people || note.actors actors =people || note.actors
number_of_actors = actors.count number_of_actors = actors.size
sentence_translations = {:two_words_connector => " #{t('notifications.index.and')} ", :last_word_connector => ", #{t('notifications.index.and')} " } sentence_translations = {:two_words_connector => " #{t('notifications.index.and')} ", :last_word_connector => ", #{t('notifications.index.and')} " }
actor_links = actors.collect{ |person| actor_links = actors.collect{ |person|
person_link(person, :class => 'hovercardable') person_link(person, :class => 'hovercardable')