Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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>();
         }
     }
 }
Exemplo 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.");
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds the child.
 /// </summary>
 /// <param name="elementToAdd">Element to add.</param>
 public void AddChild(IRateable elementToAdd)
 {
     Children.Add (elementToAdd);
 }