Skip to content

Instantly share code, notes, and snippets.

Created July 27, 2012 10:21
Show Gist options
  • Save anonymous/3187299 to your computer and use it in GitHub Desktop.
Save anonymous/3187299 to your computer and use it in GitHub Desktop.
Trending Alogirithm
DateTimeOffset startingPoint = new DateTimeOffset(2008, 4, 1, 0, 0, 0, TimeSpan.Zero);
// this calculates a score to be used for how hot an Audio is, a boost is given to Downloads over plays, same for likes and favourites
// with a favourite the most valuable, a single favourite stat is worth 20 points where as a play is just 1 point
var playScore = Math.Max(TotalPlays / 1.5, 1);
var downloadScore = Math.Max(TotalDownloads * 2, 1);
var likesScore = Math.Max(TotalLikes * 4, 1);
var favScore = Math.Max(TotalFavourites * 5, 1);
var score = Math.Log10(playScore + downloadScore + likesScore + likesScore + favScore);
double seconds = (this.DateAdded - startingPoint).TotalSeconds;
// 200,000 seconds = 55.55 hours - the higher this value the more weight is given to older audio documents
// currently this will give good weight to audios with high stats that are around 10 days old
// may nead to be tweaked to get better results
var result = Math.Pow(Math.Round(score + (seconds / 2000000), 7), 0.25);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment