'Returns the average rating for an item.'

def get_ave_item_rating_data(self, db_session, item, webapp_model=None):

    if (webapp_model is None):
        webapp_model = galaxy.model
    item_rating_assoc_class = self._get_item_rating_assoc_class(item, webapp_model=webapp_model)
    if (not item_rating_assoc_class):
        raise RuntimeException(('Item    does    not    have    ratings:    %s' % item.__class__.__name__))
    item_id_filter = self._get_item_id_filter_str(item, item_rating_assoc_class)
    ave_rating = db_session.query(func.avg(item_rating_assoc_class.rating)).filter(item_id_filter).scalar()
    if ave_rating:
        ave_rating = float(ave_rating)
    else:
        ave_rating = 0
    num_ratings = int(db_session.query(func.count(item_rating_assoc_class.rating)).filter(item_id_filter).scalar())
    return (ave_rating, num_ratings)
