$def with(work) $ rating_stats = work and work.get_rating_stats() or {} $ stats_by_bookshelf = work and work.get_num_users_by_bookshelf() or {} $ avg = rating_stats.get('avg_rating')