diff --git a/app/controllers/Coach.scala b/app/controllers/Coach.scala index 9fc6bd67b4..ab54cd1799 100644 --- a/app/controllers/Coach.scala +++ b/app/controllers/Coach.scala @@ -16,6 +16,19 @@ object Coach extends LilaController { } } + def ask(username: String) = Open { implicit ctx => + import lila.coach.{ Question, Dimension, Metric } + Accessible(username) { user => + env.api.ask(Question[lila.coach.Ecopening, Dimension[lila.coach.Ecopening]]( + xAxis = Dimension.Opening: Dimension[lila.coach.Ecopening], + yAxis = Metric.Movetime, + filters = Nil + ), user) map { answer => + Ok(html.coach.answer(answer, user)) + } + } + } + private def Accessible(username: String)(f: lila.user.User => Fu[Result])(implicit ctx: Context) = lila.user.UserRepo named username flatMap { case None => notFound diff --git a/app/views/coach/answer.scala.html b/app/views/coach/answer.scala.html new file mode 100644 index 0000000000..3d75324097 --- /dev/null +++ b/app/views/coach/answer.scala.html @@ -0,0 +1,6 @@ +@(answer: lila.coach.Answer[_, _], u: User)(implicit ctx: Context) + +@coach.layout(u, title = s"${u.username} coach") { + +@answer +} diff --git a/conf/routes b/conf/routes index 8a31447022..f9b650d026 100644 --- a/conf/routes +++ b/conf/routes @@ -44,6 +44,7 @@ GET /rel/blocks controllers.Relation.blocks # Coach POST /coach/refresh/:username controllers.Coach.refresh(username: String) +GET /coach/:username controllers.Coach.ask(username: String) # User GET /@/:username/opponents controllers.User.opponents(username: String) diff --git a/modules/coach/src/main/CoachApi.scala b/modules/coach/src/main/CoachApi.scala index 7f38e5fd38..932caa38ee 100644 --- a/modules/coach/src/main/CoachApi.scala +++ b/modules/coach/src/main/CoachApi.scala @@ -36,7 +36,7 @@ final class CoachApi(coll: Coll) { } } - private val unwindMoves = Unwind("$moves").some + private val unwindMoves = Unwind("moves").some private val sortNb = Sort(Descending("nb")).some private def limit(nb: Int) = Limit(nb).some