mirror of
https://github.com/lichess-org/lila.git
synced 2026-05-26 13:51:00 +00:00
remove Option.soFu and use traverse instead, rename Boolean.soFu to optionFu
38 lines
927 B
Scala
38 lines
927 B
Scala
package controllers
|
|
|
|
import play.api.libs.json.*
|
|
|
|
import lila.app.*
|
|
|
|
final class Learn(env: Env) extends LilaController(env):
|
|
|
|
import lila.learn.LearnHandlers.given
|
|
|
|
def index = Open(serveIndex)
|
|
def indexLang = LangPage(routes.Learn.index)(serveIndex)
|
|
|
|
private def serveIndex(using ctx: Context) = NoBot:
|
|
pageHit
|
|
ctx.me
|
|
.traverse: me =>
|
|
env.learn.api.get(me).map(Json.toJson)
|
|
.flatMap: progress =>
|
|
Ok.page(views.learn(progress))
|
|
|
|
def score = AuthBody { ctx ?=> me ?=>
|
|
bindForm(lila.learn.StageProgress.form)(
|
|
jsonFormError,
|
|
(stage, level, s) =>
|
|
val score = lila.learn.StageProgress.Score(s)
|
|
for
|
|
_ <- env.learn.api.setScore(me, stage, level, score)
|
|
_ <- env.activity.write.learn(me, stage)
|
|
yield jsonOkResult
|
|
)
|
|
}
|
|
|
|
def reset = AuthBody { _ ?=> me ?=>
|
|
for _ <- env.learn.api.reset(me)
|
|
yield jsonOkResult
|
|
}
|