我担心仪表板视图的控制器方法上显示的信息量。基本上,这个仪表板视图显示了我的应用程序中的用户信息和活动,但我认为这很快就会变成一团糟,因为传递给视图的信息量很大。
@answered = answered.length
@asked = asked.length
@pending = pending.length
@favorited = favorited.length
@medal_gold = thanks_received(:awesome).length
@medal_silver = thanks_received(:great).length
@medal_bronze = thanks_received(:good).length
@notification_pending = question_users_not_seen(pending, current_user.user_notification.pending_last_seen).count
@notification_silver = question_users_not_seen(thanks_received(:great), current_user.user_notification.silver_last_seen).count
@notification_gold = question_users_not_seen(thanks_received(:awesome), current_user.user_notification.gold_last_seen).count
@notification_bronze = question_users_not_seen(thanks_received(:good), current_user.user_notification.bronze_last_seen).count
@notification_asked = question_users_not_seen(asked, current_user.user_notification.asked_last_seen).any?
@notification_answered = question_users_not_seen(answered, current_user.user_notification.answered_last_seen).any?
@notification_favorited = question_users_not_seen(favorited, current_user.user_notification.favorited_last_seen).any?
有没有更优雅的方式来编写所有这些信息?我只担心代码的外观,而不是它的性能。