def get_single_bus_data_ios(b, user): if b.lat == 0 or b.lon == 0: b = setBusLatLng(b) d = dict() d["businessID"] = b.id d["businessName"] = b.name d["businessCity"] = b.city d["businessState"] = b.state d["streetAddr"] = b.address d["latitude"] = b.lat d["longitude"] = b.lon d["businessID"] = b.id d["businessPhone"] = "555 555-5555" d["distanceFromCurrentUser"] = str(b.get_distance(user)) d["ratingOverAllUsers"] = round(getBusAvg(b.id) * 2) / 2 d["photo"] = get_photo_url(b) d["numberOfRatings"] = getNumRatings(b.id) d["numberOfLoves"] = getNumLoved(b) d["numberOfLikes"] = getNumLiked(b) # the user exists and has rated something if user and Rating.objects.filter(user=user, business=b).count() > 0: try: r = Rating.objects.get(user=user, business=b) except Rating.MultipleObjectsReturned: r = Rating.objects.filter(user=user, business=b)[0] d["ratingForCurrentUser"] = r.rating else: d["ratingForCurrentUser"] = 0 bustags = BusinessTag.objects.filter(business=b) # .exclude(tag=get_master_summary_tag()) d["categories"] = [] for bt in bustags: d["categories"].append(get_category_data(bt, user)) if d["ratingForCurrentUser"] == 0: # b.recommendation = get_best_current_recommendation(b, user) d["ratingRecommendation"] = getBusAvg(b.id) return d
def score_weight(user,b): if user and BusinessRating.objects.filter(user=user, business=b).count() > 0: try: score = BusinessRating.objects.get(user=user, business=b).BusinessRating except BusinessRating.MultipleObjectsReturned: score = BusinessRating.objects.filter(user=user,business=b)[0].BusinessRating else: #TODO GET RECOMMENDATION HERE!!!!!! score = getBusAvg(b.id) return float(score) / float(MAX_RATING)