nicer player elo chart

pull/1/merge
Thibault Duplessis 2012-06-01 21:37:14 +02:00
parent 62e87b962e
commit af53d893d3
3 changed files with 15 additions and 7 deletions

View File

@ -7,7 +7,7 @@ import play.api.templates.Html
trait AssetHelper {
val assetVersion = 8
val assetVersion = 9
def cssTag(name: String) = css("stylesheets/" + name)

View File

@ -4,18 +4,23 @@ package user
import scala.math.round
import scalaz.effects._
import com.codahale.jerkson.Json
import org.joda.time.DateTime
import org.joda.time.format.{ DateTimeFormat, DateTimeFormatter }
final class EloChart(elos: List[(Int, Int)]) {
private val points = 100
private val formatter: DateTimeFormatter =
DateTimeFormat forPattern "dd/MM/yy"
def columns = EloChart.columns
val rows = Json generate {
def rows = Json generate {
reduce(elos) map {
case (ts, elo) ts :: elo :: Nil
}
}
case (ts, elo) date(ts) :: elo :: Nil
}
}
private def reduce(elos: List[(Int, Int)]) = {
val size = elos.size
@ -26,12 +31,15 @@ final class EloChart(elos: List[(Int, Int)]) {
}) :+ elos.last
})
}
// ts is in seconds
def date(ts: Long): String = formatter print new DateTime(ts * 1000)
}
object EloChart {
val columns = Json generate List(
"number" :: "Game" :: Nil,
"string" :: "Game" :: Nil,
"number" :: "Elo" :: Nil)
def apply(historyRepo: HistoryRepo)(user: User): IO[Option[EloChart]] =

View File

@ -33,7 +33,7 @@ div.user_show .elo_history {
display: block;
width: 460px;
height: 320px;
margin-top: -15px;
margin-top: -36px;
}
div.user_show .win_stats {