Show user's best perf in rating graph navigator
parent
26069874ed
commit
fc12506c37
|
@ -30,7 +30,7 @@ object perfStat {
|
||||||
frag(
|
frag(
|
||||||
jsTag("chart/ratingHistory.js"),
|
jsTag("chart/ratingHistory.js"),
|
||||||
embedJsUnsafeLoadThen(
|
embedJsUnsafeLoadThen(
|
||||||
s"lichess.ratingHistoryChart($rc,'${perfType.trans(lila.i18n.defaultLang)}');"
|
s"lichess.ratingHistoryChart($rc,{singlePerfName:'${perfType.trans(lila.i18n.defaultLang)}'});"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import lila.app.ui.ScalatagsTemplate._
|
||||||
import lila.common.paginator.Paginator
|
import lila.common.paginator.Paginator
|
||||||
import lila.game.Game
|
import lila.game.Game
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
import lila.history.RatingChartApi
|
||||||
|
|
||||||
object page {
|
object page {
|
||||||
|
|
||||||
|
@ -84,7 +85,9 @@ object page {
|
||||||
info.ratingChart.map { ratingChart =>
|
info.ratingChart.map { ratingChart =>
|
||||||
frag(
|
frag(
|
||||||
jsTag("chart/ratingHistory.js"),
|
jsTag("chart/ratingHistory.js"),
|
||||||
embedJsUnsafeLoadThen(s"lichess.ratingHistoryChart($ratingChart)")
|
embedJsUnsafeLoadThen(
|
||||||
|
s"lichess.ratingHistoryChart($ratingChart,{perfIndex:${RatingChartApi.bestPerfIndex(info.user)}})"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
withSearch option jsModule("gameSearch"),
|
withSearch option jsModule("gameSearch"),
|
||||||
|
|
|
@ -43,24 +43,7 @@ final class RatingChartApi(
|
||||||
historyApi get userId map2 { (history: History) =>
|
historyApi get userId map2 { (history: History) =>
|
||||||
lila.common.String.html.safeJsonValue {
|
lila.common.String.html.safeJsonValue {
|
||||||
Json.toJson {
|
Json.toJson {
|
||||||
import lila.rating.PerfType._
|
RatingChartApi.perfTypes map { pt =>
|
||||||
List(
|
|
||||||
Bullet,
|
|
||||||
Blitz,
|
|
||||||
Rapid,
|
|
||||||
Classical,
|
|
||||||
Correspondence,
|
|
||||||
Chess960,
|
|
||||||
KingOfTheHill,
|
|
||||||
ThreeCheck,
|
|
||||||
Antichess,
|
|
||||||
Atomic,
|
|
||||||
Horde,
|
|
||||||
RacingKings,
|
|
||||||
Crazyhouse,
|
|
||||||
Puzzle,
|
|
||||||
UltraBullet
|
|
||||||
) map { pt =>
|
|
||||||
Json.obj(
|
Json.obj(
|
||||||
"name" -> pt.trans(lila.i18n.defaultLang),
|
"name" -> pt.trans(lila.i18n.defaultLang),
|
||||||
"points" -> ratingsMapToJson(userId, createdAt, history(pt))
|
"points" -> ratingsMapToJson(userId, createdAt, history(pt))
|
||||||
|
@ -72,3 +55,27 @@ final class RatingChartApi(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object RatingChartApi {
|
||||||
|
|
||||||
|
def bestPerfIndex(user: User): Int = user.bestPerf ?? { perfTypes indexOf _ }
|
||||||
|
|
||||||
|
import lila.rating.PerfType._
|
||||||
|
private val perfTypes = List(
|
||||||
|
Bullet,
|
||||||
|
Blitz,
|
||||||
|
Rapid,
|
||||||
|
Classical,
|
||||||
|
Correspondence,
|
||||||
|
Chess960,
|
||||||
|
KingOfTheHill,
|
||||||
|
ThreeCheck,
|
||||||
|
Antichess,
|
||||||
|
Atomic,
|
||||||
|
Horde,
|
||||||
|
RacingKings,
|
||||||
|
Crazyhouse,
|
||||||
|
Puzzle,
|
||||||
|
UltraBullet
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -106,6 +106,8 @@ case class User(
|
||||||
|
|
||||||
def best3Perfs: List[PerfType] = bestOf(User.firstRow, 3)
|
def best3Perfs: List[PerfType] = bestOf(User.firstRow, 3)
|
||||||
|
|
||||||
|
def bestPerf: Option[PerfType] = bestOf(User.firstRow ::: User.secondRow, 1) headOption
|
||||||
|
|
||||||
def hasEstablishedRating(pt: PerfType) = perfs(pt).established
|
def hasEstablishedRating(pt: PerfType) = perfs(pt).established
|
||||||
|
|
||||||
def isPatron = plan.active
|
def isPatron = plan.active
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
lichess.ratingHistoryChart = function (data, singlePerfName) {
|
lichess.ratingHistoryChart = function (data, { singlePerfName, perfIndex }) {
|
||||||
var oneDay = 86400000;
|
var oneDay = 86400000;
|
||||||
function smoothDates(data) {
|
function smoothDates(data) {
|
||||||
if (!data.length) return [];
|
if (!data.length) return [];
|
||||||
|
@ -96,6 +96,9 @@ lichess.ratingHistoryChart = function (data, singlePerfName) {
|
||||||
lineWidth: 0,
|
lineWidth: 0,
|
||||||
tickWidth: 0,
|
tickWidth: 0,
|
||||||
},
|
},
|
||||||
|
navigator: {
|
||||||
|
baseSeries: perfIndex,
|
||||||
|
},
|
||||||
scrollbar: disabled,
|
scrollbar: disabled,
|
||||||
series: data
|
series: data
|
||||||
.filter(function (v) {
|
.filter(function (v) {
|
||||||
|
|
Loading…
Reference in New Issue