static double GetPoints(IRateable rateable, double avgPopularity) { if (rateable.Rating.Count == 0) { return(rateable.AvgPoints); } return(rateable.AvgPoints * (rateable.Rating.Popularity / avgPopularity)); }
public void UserRate(IRateable rateable, IRatingSystem system) { Request r = new Request(); r.UserKarma = UserKarma; r.UserRate = GetUserRate(); r.Rateable = rateable; r.Recommended = Recommended; system.Requests.Enqueue(r); }
private static double GetPoints(IRateable rateable, double avgPopularity) { double timeFactor = Math.Pow(0.99, (DateTime.UtcNow - rateable.Timestamp).Days); if (rateable.Rating.Count == 0) { return(timeFactor * rateable.AvgPoints); } return(timeFactor * rateable.AvgPoints * (rateable.Rating.Popularity / avgPopularity)); }
public void Refresh() { if (Rateables.Count < NumberOfTop) { Rateables.Add(MinRateable); } else { IRateable temp = Rateables.Min <IRateable>(); if (MinRateable.RateValue > temp.RateValue) { Rateables.Remove(temp); Rateables.Add(MinRateable); MinRateable = Rateables.Min <IRateable>(); } } }
/// <summary> /// Removes the child. /// </summary> /// <returns>The removed child.</returns> /// <param name="elementToRemove">Element to remove.</param> public IRateable RemoveChild(IRateable elementToRemove) { if (Children.Remove (elementToRemove)) return elementToRemove; else throw new InvalidOperationException ("Unable to remove the specified element."); }
/// <summary> /// Adds the child. /// </summary> /// <param name="elementToAdd">Element to add.</param> public void AddChild(IRateable elementToAdd) { Children.Add (elementToAdd); }