refactor get_average_rating method to use one-line inject