//Karthik Srinivasan

Product Engineer, CTO & a Beer Enthusiast
Experiments, thoughts and scripts documented for posterity.

Quirky Personal Projects

LinkedIn

Email me

Hot Scoring Sort

Nov 10, 2017

Based on the difference between ups/downs, and decays with time. Basically hive mind effects. 

This is based on Reddit Scoring system blog post

Scala:

private def getHotScore(pageViews: Double, conversionCount: Double, releaseDate: Option[String]): Double = {
    import com.github.nscala_time.time.Imports._
    try {
      val decay: Double = 45000;
      val skuScore: Double = (if (pageViews <= 0) 0 else Math.log(pageViews)) + (if (conversionCount <= 0) 0 else Math.log(conversionCount))
      val sign: Double = Math.signum(skuScore)
      val order: Double = Math.log(Math.max(Math.abs(skuScore), 1)) / 2.3025
      val secAge: Double = if (releaseDate == None) 1000 else (DateTime.parse(releaseDate.get) to DateTime.now()).millis / 1000
      (sign * order) - (secAge / decay)
    } catch {
      case e: Exception => {
        println(releaseDate)
        0
      }
    }
  }