Esempio n. 1
0
        static double GetPoints(IRateable rateable, double avgPopularity)
        {
            if (rateable.Rating.Count == 0)
            {
                return(rateable.AvgPoints);
            }

            return(rateable.AvgPoints * (rateable.Rating.Popularity / avgPopularity));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 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>();
         }
     }
 }
Esempio n. 5
0
 /// <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.");
 }
Esempio n. 6
0
 /// <summary>
 /// Adds the child.
 /// </summary>
 /// <param name="elementToAdd">Element to add.</param>
 public void AddChild(IRateable elementToAdd)
 {
     Children.Add (elementToAdd);
 }