def highlight_rating_star(count, packageId): """ Accepts a rating value and returns a 1 to indicate that a star must be highlighted on the UI to indicate a rating, and a 0 to not highlight it. """ package = model.Package.get(packageId) if rating.get_rating(package)[0] >= count: return 1 else: return 0
def get_rating_details(package_id): """ Returns the average rating of a package for a given package id and the number of ratings. """ rating_obj = rating.get_rating(model.Package.get(package_id)) rating_v = rating_obj[0] or 0 ratings_count = rating_obj[1] rnd = round(rating_v) intv = int(rnd) return intv, ratings_count
def count_rating_reviews(packageId): package = model.Package.get(packageId) if (rating.get_rating(package)): return rating.get_rating(package)[1] else: return 0